Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: trying to bind a picture box to an access database

  1. #1
    Join Date
    Sep 2005
    Posts
    33
    Rep Power
    0

    Default trying to bind a picture box to an access database

    I am trying to bind a picture box to my access database, i am using typed dataset ,but whenever i click on the databindings property of the picture box and click on "tag" it shows me all the columns in the access table but when i try to click on the column i would like it to bind to it's not accepting it but if i try to bind it to another column it accepts it , i am not sure if anyone understands what i am trying to say but if you do and think u can help me can u please reply to this post..
    My project is basically to create a database which includes the names and title of employees and a photograph, everything else i can add to the database except the photo, i don't know how to save it to the database so i was trying to bind it but that doesn't seem to work

    thanks

  2. #2
    Join Date
    Jan 2006
    Posts
    74
    Rep Power
    0

    Default

    You will be required to supply the following:

    OS, Programming language and version, Image format (JPG,TIFF, PNG, BMP etc.) Database type.

  3. #3
    Join Date
    Dec 2002
    Posts
    500
    Rep Power
    0

    Default

    you cant bind directly to the image coming from the database(dataset)...
    well you can, you have to get the binding object that corresponds to the Binding and implement the Parse and Format events.

    In the parse you would convert the byte[] that is in the dataset to and Image.

    In the format event handler you convert the Image back to a byte[]

    converting usually follows the following routine:

    A. Create a MemoryStream
    B. Write the byte[] to the stream (or save the Image to the MemoryStream)
    C. use Read to read the Image (get the byte[] array) from the MemoryStream

    Read up on the classes or just google it you may find a working solution.
    Cultured in Aggression and Koding like a Warrior!!
    “Common sense is instinct. Enough of it is genius.” - George Bernard Shaw.
    "The significant problems we face cannot be solved by the same level of thinking that created them." - Albert Einstein

  4. #4
    Join Date
    Sep 2005
    Posts
    33
    Rep Power
    0

    Default

    Thanks for replying but i have tried google and other searches but i can't come up with a simple solution and i am kinda new so i don't know much about .NET i am actually self taught and just trying stuff
    you think you could give me an example please

    The language i am using is visual basic.net 2003 , and it's a office xp version of windows Microsoft Access Database i am using , and i would like to use JPG file format for my images

  5. #5
    Join Date
    Sep 2004
    Posts
    1,905
    Rep Power
    21

    Default

    I am trying to get a laptop so that I can help too cause some things I can't give code examples of my memory.

    I know icymint is right, so what u need is probly to compare that data binding code that you have already for the other columns and look up the 'meanings' of the code. See how you can display an image onto a window Form

    MemoryStream is a class that can stream data from memory. You could implement a memory stream to read and write this data. There is one already in the VB.Net library. Say you wanted to read every odd byte from a stream of bytes in memory, then you could implement you own Read method, so when you call Read(5) then 5 odd bytes are read from the stream. A stream is basically a flow of data and you can control how the data will go in the stream. Using a memory stream in this case is simply to just pust the data from the access table into the memory of the computer where you can stream the contents into other datatypes such as a Image object.

    You should look at the Image class and its method as well.
    Let's act on what we agree on now, and argue later on what we don't.
    Black men leave Barbeque alone if Barbeque don't trouble you

  6. #6
    Join Date
    Sep 2005
    Posts
    33
    Rep Power
    0

    Default

    well thanks for trying to help , i guess i will have to do some more reading or just forget about using the picture box in my project

    nuff respect

  7. #7
    Join Date
    Sep 2005
    Posts
    33
    Rep Power
    0

    Default

    i was just thinking, could i save the path of the picture file to the database and when the user clicks on a particular name the image is automatically loaded in the picture box .. is that possible and if yes how would i implement that..?

  8. #8
    Join Date
    Sep 2004
    Posts
    1,905
    Rep Power
    21

    Default

    Yes

    Quote Originally Posted by owayneb
    I am trying to bind a picture box to my access database, i am using typed dataset ,but whenever i click on the databindings property of the picture box and click on "tag" it shows me all the columns in the access table but when i try to click on the column i would like it to bind to it's not accepting it but if i try to bind it to another column it accepts it , i am not sure if anyone understands what i am trying to say but if you do and think u can help me can u please reply to this post..
    My project is basically to create a database which includes the names and title of employees and a photograph, everything else i can add to the database except the photo, i don't know how to save it to the database so i was trying to bind it but that doesn't seem to work

    thanks
    I read this over now.

    You can put pictures in an Access database by using binary(OLE Object) or text(Base64Encoded). The latter must be done programmatically only. You can also pass the file path of a picture file to the text column of the Access table. This may be an easier implementation. This pretty much straight forward but it is not databinding. Eg. Get the 'name' and query the database for the 'file path' and use the path to load a picture in the picture box. I would use a database though for a desktop application.

    Databinding is the process of linking two data types together. eg, a List box (of texts) can be data bound to a text column(of texts) in a datatable. When one data is changed then the other data changes as well. The two data types must be interconvertable. For a Picture box, the binding should be a single compatible picture, in theory. If binding is not allowed in the properties pane in VS then use a code around to achieve the same effect as binding, just make sure that the data stored in the database is compatible are converted to the same datatype for the Picture box and load the data into the picture box.

    Sorry I can't helpp you more with the code.
    Let's act on what we agree on now, and argue later on what we don't.
    Black men leave Barbeque alone if Barbeque don't trouble you

  9. #9
    Join Date
    Sep 2005
    Posts
    33
    Rep Power
    0

    Default

    hey crosswire just wanna say "nuff respect" zeen i think i am going to try saving the picture path to the database
    will tell you how it work out zeen

  10. #10
    Join Date
    Dec 2002
    Posts
    500
    Rep Power
    0

    Default

    dont giv' up, mi might code it over the weekend if i have time.
    Cultured in Aggression and Koding like a Warrior!!
    “Common sense is instinct. Enough of it is genius.” - George Bernard Shaw.
    "The significant problems we face cannot be solved by the same level of thinking that created them." - Albert Einstein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •