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.

Recommended Answers

All 2 Replies

What do you mean by created database with ms .You are using MS Access or MS Sql Server ?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.