VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Retrive the image from database display the picture box

by Sampath Kumar (2 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 3rd February 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Retrive the image from database display the picture box

API Declarations


Dim rs As ADODB.Recordset
Dim DataFile As Integer, Fl As Long, Chunks As Integer
Dim Fragment As Integer, Chunk() As Byte, i As Integer, FileName As String
Const ChunkSize As Integer = 16384
Const conChunkSize = 100

Rate Retrive the image from database display the picture box



    cn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Pubs;Data Source=Test"
    Dim strsql As String

    Set rs = Nothing
    Set rs = New Recordset
    strsql = "SELECT * FROM pub_info where pub_id = '9999'"
    rs.Open strsql, cn, adOpenForwardOnly, adLockReadOnly
    ShowPic

End Sub



Private Sub ShowPic()
    DataFile = 1
    Open "pictemp" For Binary Access Write As DataFile
        Fl = rs!logo.ActualSize ' Length of data in file
        If Fl = 0 Then Close DataFile: Exit Sub
        Chunks = Fl \ ChunkSize
        Fragment = Fl Mod ChunkSize
        ReDim Chunk(Fragment)
        Chunk() = rs!logo.GetChunk(Fragment)
        Put DataFile, , Chunk()
        For i = 1 To Chunks
            ReDim Buffer(ChunkSize)
            Chunk() = rs!logo.GetChunk(ChunkSize)
            Put DataFile, , Chunk()
        Next i
    Close DataFile
    FileName = "pictemp"
    Picture1.Picture = LoadPicture(FileName)
End Sub


Download this snippet    Add to My Saved Code

Retrive the image from database display the picture box Comments

No comments have been posted about Retrive the image from database display the picture box. Why not be the first to post a comment about Retrive the image from database display the picture box.

Post your comment

Subject:
Message:
0/1000 characters