-
Oct 13th, 2008, 01:35 AM
#1
Thread Starter
Frenzied Member
[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
Last edited by longwolf; Oct 14th, 2008 at 02:01 AM.
-
Oct 13th, 2008, 11:49 AM
#2
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.
The best argument against democracy is a five minute conversation with the average voter - Winston Churchill
Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd
-
Oct 13th, 2008, 12:59 PM
#3
Thread Starter
Frenzied Member
Re: VB6 Compare pictures stored in two DBs
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
-
Oct 13th, 2008, 01:05 PM
#4
Thread Starter
Frenzied Member
Re: VB6 Compare pictures stored in two DBs
Hot digity! I figured it out.
Code:
PictureMatch = CStr(rsI.Fields("Image")) = CStr(rsO.Fields("Image"))
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|