I would like to ask for vb6 sample on how save and retrieve image in mysql database. tnx
Printable View
I would like to ask for vb6 sample on how save and retrieve image in mysql database. tnx
You can find what you are looking for in the Database Development FAQ
ok but the sample there is using access db. I am looking for mysql db.
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
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?
confirmation here on the above post please
up on this please
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
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.
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
up on this
never seen it done that way... usually it's saved to a file, then the file it loaded into the Image control.
-tg
it was the sample code given in the database development faq by nightwalker and I tried it and I got error.
try this sir
imgfile.Open
imgfile.Type = adTypeBinary
imgfile.LoadFromFile CommonDialog1.FileName
rs.Fields("photo") = imgfile.Read
rs.Update
'''''variable img is a stream
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
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.
any idea why this error comes up?
You should be binding the Image control to a field in the recordset, not the recordset itself, I'd have thought...
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
I am having the same problem!
Edit:
If you put
vb Code:
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.
Attachment 95965
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.