Data type mismatch in criteria expression
Posted on 2014-02-25
Dim holdlong As Long = CLng(Dst4.Tables(0).Rows(0).Item(0))
Dim DadSocSec As OleDbDataAdapter = New OleDbDataAdapter("Select * From EmployeeCompInfo where EMPLOYEEID= '" & holdlong & "' ", Con)
holdlong is a 3
EMPLOYEEID is a field with a 3 in it
Dim DstSocSec As DataSet = New DataSet
at this point I get this error: Data type mismatch in criteria expression
usually when you see this error the field is spelled wrong but it is not.
EMPLOYEEID is a long because it is the reference back to a another table which is the auto number primary key; auto numbers are longs. I cast it just to make sure, but no matter it comes up as 3.
if I get rid of the where clause the query runs just fine, so the data mismatch is in the where clause but I don't see it.