0

HI
I have created database with ms and linked it with vb6 user interface.But i have a problem linking or loading pictures to the records.I need help on how this can be done,and if possible how pictures can be loaded with it's corresponding data into the database at runtime.
Thank you.

3
Contributors
2
Replies
5
Views
10 Years
Discussion Span
Last Post by dilip_singh3
0

here is a sample code for it

Private Sub Savephoto()
On Error GoTo savePhoto_Error

Dim rsIMG As New ADODB.Recordset
Dim bytBLOB() As Byte
Dim intNum As Integer
Set rsIMG = New ADODB.Recordset
rsIMG.ActiveConnection = CNN
rsIMG.CursorType = adOpenKeyset
rsIMG.LockType = adLockPessimistic 'Invoke Pessimistic Locking
rsIMG.CursorLocation = adUseServer
rsIMG.Open "Select * from em where emp_id = " & ID
With rsIMG
intNum = FreeFile
Open txt_IMGnm.Text For Binary As #intNum
ReDim bytBLOB(FileLen(txt_IMGnm.Text)) 'Read data and close file
Get #intNum, , bytBLOB
Close #1
.Fields("Photo").AppendChunk bytBLOB 'Store the BLOB
.Update
End With
rsIMG.MoveFirst
Exit Sub

savePhoto_Error:
MsgBox Err.Description
End Sub

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.