Results 1 to 4 of 4

Thread: [RESOLVED] VB6 Compare pictures stored in two DBs

  1. #1

    Thread Starter
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Resolved [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.

  2. #2
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,900

    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

  3. #3

    Thread Starter
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    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

  4. #4

    Thread Starter
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    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
  •  



Click Here to Expand Forum to Full Width