Wednesday, March 21, 2012

Image data type. Tricks and tips anyone?

Tools I want to use...

Sql2k/MSDE
ADO 2.x
VB6

Before I waste time experimenting, thought I'd ask the veterans:

I want to store Jpgs into a table, using the image datatype.

Will ADO auto-magically pick up that I'm streaming an image in when I try to do this...

Dim Pic as StdPicutre, RS as ADODB.Recordset
RS.open "select * from...."
set pic = Rs!MyImage

Or do I have to go through bizarre motions like this...

Dim Pic as StdPicutre, RS as ADODB.Recordset
Dim Blob() as byte

Blob = rs!MyImage

Open MyFilePath for Binary as #FileNum
Put #FileNum,,Blob
Close #FileNum

Set Pic = LoadPicture(MyFilePath)

Any thoughts?

(Please don't recommended linked controls, I hate those damn things with a passion.)

Thanks for reading!Agree about linked controls.
If you search you can find code related to inserting images.
Do you need to hold them in the database?
I usually hold them in files on the ado application server with the filename in the database - this saves the network traffic in saving and retrieving and gets round the transaction/trigger issues.|||I found some code, yes. All ways to acomplish this are easy, don't get me wrong...just looking for the simplest solution.

You seam to be implying that you do not recomend storing the actually image bits in the database itself...at all. The system you talk off is similar to what I'm doing now.

If it's not broken, don't fit it?

Is there anything to gain by placing these images into a table?

Thanks!|||Don't see what you would gain - you can't do a lot with them anyway.
If you do want to save them in a table then I would make this a separate database so that it doesn't compromise the rest of the data.
Would still prefer to leave them in files though.

No comments:

Post a Comment