Binding a Picture object to a Image data type field

Hello,

In a VB6 SQL 2000 application, I use an Image data type field to store .bmp file.

Is there a way to display the bmp file in a Picture object without having to save the file locally?
I know I can save the file somewhere using

    Dim rs         As ADODB.Recordset
    Dim stmDocTest As ADODB.Stream
    Dim strFile    As String

    Set stmDocTest = New ADODB.Stream
    stmDocTest.Type = adTypeBinary
    stmDocTest.Open
    stmDocTest.Write rsDocument!docInsert
   
    strFile = App.Path & "\TEMP\"
    stmDocTest.SaveToFile strFile, adSaveCreateOverWrite

I would like to bind directly the Picture object to the Image data field without having to save the file locally
Something like...

   Set Picture1.Picture = rsDocument!docInsert  (wich does work)

 .... without having to save the file locally is my key issue

Thank you

Mario
MarioCantinAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HoweverCommaCommented:
The problem is that loading from a file is built in to the picture box control, that is the only way it knows how to do it.
You can 'trick' it though, just place your picturebox wherever you want it to be.
Then you will have to use some API calls to modify the hDC (windows device handle to the bitmap displayed), in VB you can not change the hDC property it is read only you can modify the BMP that the hDC points to. Unless you want to go the route of setting pixels manually (your own BMP decode routine NOT recommended) or find a custom Picturebox replacement that will load from a stream then this is the only way I can think of doing this. You may need more robust support you can get the BMP header info for the formats you desire to support by searching for "BMP file structure" and replacing the code in this accordingly. This should get you going.

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20608231.html 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.