Results 1 to 22 of 22

Thread: how save and retrieve image in mysql database

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2013
    Posts
    148

    how save and retrieve image in mysql database

    I would like to ask for vb6 sample on how save and retrieve image in mysql database. tnx

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: how save and retrieve image in mysql database

    You can find what you are looking for in the Database Development FAQ
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2013
    Posts
    148

    Re: how save and retrieve image in mysql database

    ok but the sample there is using access db. I am looking for mysql db.

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: how save and retrieve image in mysql database

    Interestingly binary is binary... making the techniques essentially the same... the only variation might be the connectionstring, and maybe the SQL... but other than that...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2013
    Posts
    148

    Re: how save and retrieve image in mysql database

    techgnome, do you mean that storing and retrieving images in access database using vb6 coding is the same as storing and retrieving images in mysql database?

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2013
    Posts
    148

    Re: how save and retrieve image in mysql database

    confirmation here on the above post please

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jan 2013
    Posts
    148

    Re: how save and retrieve image in mysql database

    up on this please

  8. #8
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: how save and retrieve image in mysql database

    One of the most valuable skills in programming is experimentation... so why don't you give it a try? Rather than waiting for someone to do it for you, take some initiative and try it yourself. In the amount of time you've waited for someone else to try it, you could have done it, probably made a couple of mistakes, gotten them fixed and moved on.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jan 2013
    Posts
    148

    Re: how save and retrieve image in mysql database

    techgnome, yes you are right. I should have tested but I never thought of it. I have just began learning. thanks for the input. Actually I have downloaded samples but those are using access db. So I am skeptical if it also applies with mysql since they are different database.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jan 2013
    Posts
    148

    Re: how save and retrieve image in mysql database

    I tried the code and I got error "unable to bind field or datamember:"pic_sample"

    the error when debug comes from
    Set Image1.DataSource = rs
    Last edited by ravemaster; Jan 31st, 2013 at 11:45 PM.

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Jan 2013
    Posts
    148

    Re: how save and retrieve image in mysql database

    up on this

  12. #12
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: how save and retrieve image in mysql database

    never seen it done that way... usually it's saved to a file, then the file it loaded into the Image control.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Jan 2013
    Posts
    148

    Re: how save and retrieve image in mysql database

    it was the sample code given in the database development faq by nightwalker and I tried it and I got error.

  14. #14
    Member
    Join Date
    Jan 2013
    Posts
    48

    Re: how save and retrieve image in mysql database

    try this sir
    imgfile.Open
    imgfile.Type = adTypeBinary
    imgfile.LoadFromFile CommonDialog1.FileName
    rs.Fields("photo") = imgfile.Read
    rs.Update
    '''''variable img is a stream

  15. #15
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: how save and retrieve image in mysql database

    Did you follow the right link in there? You should have been reading through this one:
    http://www.vbforums.com/showthread.p...-in-a-database titled "How can I store Images in a database"....

    shoot it shows how to store, but not retrieve... but normally to retrieve the image, you have to use GETCHUNK to get the bytes, write them to a file, then load it into the image control.

    ADO doesn't have a way to specifically stream images into a control, that I'm aware of.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Jan 2013
    Posts
    148

    Re: how save and retrieve image in mysql database

    the link that you provided is the same article that I read and gave me the error "unable to bind field or datamember:"pic_sample" upon saving.

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Jan 2013
    Posts
    148

    Re: how save and retrieve image in mysql database

    any idea why this error comes up?

  18. #18
    Frenzied Member
    Join Date
    Apr 2012
    Posts
    1,272

    Re: how save and retrieve image in mysql database

    You should be binding the Image control to a field in the recordset, not the recordset itself, I'd have thought...
    If you don't know where you're going, any road will take you there...

    My VB6 love-children: Vee-Hive and Vee-Launcher

  19. #19

    Thread Starter
    Addicted Member
    Join Date
    Jan 2013
    Posts
    148

    Re: how save and retrieve image in mysql database

    If Not (rs.BOF And rs.EOF) Then
    txtDescription.Text = rs.Fields("Pict_Desc")
    Set Image1.DataSource = rs
    Image1.DataField = "Pict_Sample"
    End If

    this is the whole to retrieve and binded to datafield pict_sample but sill theres the error

  20. #20
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: how save and retrieve image in mysql database

    Quote Originally Posted by ravemaster View Post
    I tried the code and I got error "unable to bind field or datamember:"pic_sample"

    the error when debug comes from
    Set Image1.DataSource = rs
    I am having the same problem!

    Edit:

    If you put

    vb Code:
    1. Image1.DataSource = rs.Fields("Picture")

    You will receive the error "Method or data member not found".

    The problem seems to be retrieving the image from the database.

    Edit II:

    Here is the working example I created following SI's tutorial.

    Save picture.zip
    Last edited by Nightwalker83; Feb 1st, 2013 at 08:38 PM. Reason: Adding more!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  21. #21

    Thread Starter
    Addicted Member
    Join Date
    Jan 2013
    Posts
    148

    Re: how save and retrieve image in mysql database

    check the new attachment and it is adding and retrieving but my problem now is that the image show in the imagebox is really big and the retrieval is taking long like 3-4 seconds. why is that? unlike using binary and getchunk method, it is much faster and the picture is fixed on the size of the imagebox.
    Last edited by ravemaster; Feb 1st, 2013 at 09:52 PM. Reason: update post

  22. #22
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: how save and retrieve image in mysql database

    Quote Originally Posted by ravemaster View Post
    the picture is fixed on the size of the imagebox.
    Not sure what you mean but see if changing the stretch value of the image box to true helps.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

Posting Permissions

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



Click Here to Expand Forum to Full Width