[RESOLVED] VB6 Compare pictures stored in two DBs
I'm writing a DB import function in VB6 with an Access 2000 DB.
I need to test images stored in the two DBs to see if they are the same.
They are stored using RhinoBull's method.
I tried the following code, but I get a 'Type mismatch' error.
Code:
Private Function PictureMatch(ByRef OrgID As Long, ByRef ImprtID As Long) As Boolean
Dim rsO As ADODB.Recordset
Dim rsI As ADODB.Recordset
Dim sSQL As String
If OrgID = 0 Or ImprtID = 0 Then
PictureMatch = OrgID = ImprtID
Exit Function
End If
Set rsO = New ADODB.Recordset
Set rsI = New ADODB.Recordset
sSQL = "SELECT * FROM tblPics WHERE PicID = " & CStr(OrgID)
rsO.Open sSQL, cn, adOpenStatic, adLockOptimistic, adCmdText
If Not rsO.EOF Then
sSQL = "SELECT * FROM tblPics WHERE PicID = " & CStr(ImprtID)
rsI.Open sSQL, cn2, adOpenStatic, adLockOptimistic, adCmdText
If Not rsI.EOF Then
PictureMatch = rsI.Fields("Image") = rsO.Fields("Image")
End If
rsI.Close
Set rsI = Nothing
End If
rsO.Close
Set rsO = Nothing
End Function
Re: VB6 Compare pictures stored in two DBs
Where do you get the type missmatch?
I'm willing to bet (though I'm not sure) that this is you're problem:-
PictureMatch = rsI.Fields("Image") = rsO.Fields("Image")
You should do this instead
If rsI.Fields("Image") = rsO.Fields("Image") then
PictureMatch = True
Else
PictureMatch = False
End if
Also, what is the datatype of the Image column? If it's a blob you can't do a straight comparison like that AFAIK.
Re: VB6 Compare pictures stored in two DBs
Quote:
Originally Posted by FunkyDexter
Where do you get the type missmatch?
I'm willing to bet (though I'm not sure) that this is you're problem:-
PictureMatch = rsI.Fields("Image") = rsO.Fields("Image")
You should do this instead
If rsI.Fields("Image") = rsO.Fields("Image") then
PictureMatch = True
Else
PictureMatch = False
End if
Also, what is the datatype of the Image column? If it's a blob you can't do a straight comparison like that AFAIK.
I get the error on the test line: 'PictureMatch = rsI.Fields("Image") = rsO.Fields("Image")'
I tried doing the test your way before posting here, no luck.
The Image field is set as an OLE Object
Re: VB6 Compare pictures stored in two DBs
Hot digity! I figured it out.
Code:
PictureMatch = CStr(rsI.Fields("Image")) = CStr(rsO.Fields("Image"))