I using following codes to add images in my project & its working properly in winxp but not working properly in win7 platform. please help me to find the problem. If you any other better codes to add images to MS-Access databae then please suggest. thanks
Public Sub FillFields()
If Not (adorsstudent.BOF And adorsstudent.EOF) Then
Set Image1.DataSource = adorsstudent
Image1.DataField = "Picture"
End If
End Sub
Private Sub cmdAddImage_Click()
Dim bytData() As Byte
'Dim strDescription As String
On Error GoTo err
With dlImage 'common dialog box.
'filtering so only jpg's and gifs are shown!
.Filter = "Picture Files (*.jpg, *.gif)|*.jpg;*.gif"
.DialogTitle = "Select Picture" 'sets the title of it.
.ShowOpen 'show the open dialog box.
'bit to "convert" the image to binary.
Open .FileName For Binary As #1
ReDim bytData(FileLen(.FileName))
End With
Get #1, , bytData
Close #1
With adorsstudent
.Fields("Picture").AppendChunk bytData 'adding the picture to the db
End With
FillFields
Exit Sub
err:
If err.Number = 32755 Then 'simple error check.
Else
MsgBox err.Description
err.Clear
End If
End Sub