303factory
Registered User.
- Local time
- Today, 20:39
- Joined
- Oct 10, 2008
- Messages
- 136
Good morning
I'm having trouble saving a bitmap from my database to file. It's stored as the 'Image' type in my SQL Server 2008 table, and is put into the table by simply dragging a bitmap file into a bound OLE object
To retrieve it I'm trying the following code:
This creates a bitmap file in the right location, with a file size that looks about right, but it doesnt open. I've scoured the net and some forums imply that the problem is that the image file wont have correct header information etc. Is there a simple way to convert mystream binary data into a bitmap, or more simply just dump the image field content into the same format it was created with?
As always if you could point me in the right direction ill do the leg work
Regards
303
I'm having trouble saving a bitmap from my database to file. It's stored as the 'Image' type in my SQL Server 2008 table, and is put into the table by simply dragging a bitmap file into a bound OLE object
To retrieve it I'm trying the following code:
Code:
Dim strSQL As String
Set rs = New ADODB.Recordset
strSQL = "SELECT * FROM tblExhibitPhotos WHERE ID= 93 "
rs.Open strSQL, gSQLdbase, adOpenKeyset, adLockOptimistic, adCmdText
MsgBox (rs.RecordCount)
Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open
mstream.Write rs.Fields("Image").Value
mstream.SaveToFile "c:\Image.bmp", adSaveCreateOverWrite
rs.Close
This creates a bitmap file in the right location, with a file size that looks about right, but it doesnt open. I've scoured the net and some forums imply that the problem is that the image file wont have correct header information etc. Is there a simple way to convert mystream binary data into a bitmap, or more simply just dump the image field content into the same format it was created with?
As always if you could point me in the right direction ill do the leg work
Regards
303