|
-
Jan 28th, 2013, 12:27 AM
#1
Thread Starter
Addicted Member
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
-
Jan 28th, 2013, 01:30 AM
#2
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
-
Jan 28th, 2013, 02:34 AM
#3
Thread Starter
Addicted Member
Re: how save and retrieve image in mysql database
ok but the sample there is using access db. I am looking for mysql db.
-
Jan 28th, 2013, 09:57 AM
#4
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
-
Jan 28th, 2013, 06:25 PM
#5
Thread Starter
Addicted Member
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?
-
Jan 28th, 2013, 10:50 PM
#6
Thread Starter
Addicted Member
Re: how save and retrieve image in mysql database
confirmation here on the above post please
-
Jan 29th, 2013, 02:37 AM
#7
Thread Starter
Addicted Member
Re: how save and retrieve image in mysql database
-
Jan 29th, 2013, 07:00 AM
#8
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
-
Jan 29th, 2013, 08:09 AM
#9
Thread Starter
Addicted Member
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.
-
Jan 31st, 2013, 09:27 PM
#10
Thread Starter
Addicted Member
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.
-
Feb 1st, 2013, 10:27 AM
#11
Thread Starter
Addicted Member
Re: how save and retrieve image in mysql database
-
Feb 1st, 2013, 10:40 AM
#12
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
-
Feb 1st, 2013, 10:43 AM
#13
Thread Starter
Addicted Member
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.
-
Feb 1st, 2013, 11:05 AM
#14
Member
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
-
Feb 1st, 2013, 11:06 AM
#15
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
-
Feb 1st, 2013, 11:18 AM
#16
Thread Starter
Addicted Member
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.
-
Feb 1st, 2013, 11:31 AM
#17
Thread Starter
Addicted Member
Re: how save and retrieve image in mysql database
any idea why this error comes up?
-
Feb 1st, 2013, 01:12 PM
#18
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
-
Feb 1st, 2013, 01:31 PM
#19
Thread Starter
Addicted Member
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
-
Feb 1st, 2013, 07:51 PM
#20
Re: how save and retrieve image in mysql database
 Originally Posted by ravemaster
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:
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
-
Feb 1st, 2013, 09:47 PM
#21
Thread Starter
Addicted Member
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
-
Feb 2nd, 2013, 12:19 AM
#22
Re: how save and retrieve image in mysql database
 Originally Posted by ravemaster
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|