Results 1 to 3 of 3

Thread: [RESOLVED] Read/open a jpg or BMP pictures directly from SQL

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2009
    Posts
    364

    [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
    Last edited by Fraps; Mar 10th, 2010 at 11:52 AM.

  2. #2

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2009
    Posts
    364

    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
    Last edited by Fraps; Mar 10th, 2010 at 11:54 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width