[RESOLVED] Read/open a jpg or BMP pictures directly from SQL
Hi,
Is there anybody who can show me some examples how to read the jpg or bmp files stored in the MSSQL or MySQL. I know they have a binary form in the database but anyway I would like to read them in the standard PictureBox.
Currently I can upload, and save such files directly from the database.
I'm using a standard column names like Image (MSSQL) or mediumblob (MySQL)
Any clue really appreciated :)
Re: Read/open a jpg or BMP pictures directly from SQL
Follow few relevant links (save/retrieve file...) in my signature.
Re: Read/open a jpg or BMP pictures directly from SQL
Thanks Rhino, I got only the ideas.
Code:
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim mystream As ADODB.Stream
Set mystream = New ADODB.Stream
mystream.Type = adTypeBinary
conn.CursorLocation = adUseClient
Dim inptSearch As String
Set mystream = New ADODB.Stream
mystream.Type = adTypeBinary
inptSearch = fileview1.Text
Dim sql As String
sql = "Select * from Table WHERE file_name = '" & inptSearch & "'"
rs.Open sql, conn
xExt = Right(rs!File_name, 4)
mystream.Open
mystream.Write rs!File
mystream.SaveToFile App.Path & "\Temp" & xExt, adSaveCreateOverWrite
If mystream.Size > 0 Then
Image1.Visible = True
Image1.Picture = LoadPicture(App.Path & "\Temp" & xExt)
Kill App.Path & "\Temp" & xExt
Else
Image1.Visible = False
End If
mystream.Close
rs.Close