MarkItZero Posted April 18, 2003 Posted April 18, 2003 Hello, I have a program that connects to an Access database. I use an ADODB Connection to bring the data into my program. Public HeaderID as Integer Private Sub FrmExistingEstimate_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Open ADODB Connection Dim cnn1 As New ADODB.Connection() cnn1.Open("Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\Visual Studio Projects\Estimate\EstimatesDB.mdb;", _ "Admin", "") 'Query Dim Str1 As String = "Select * from EstHeader Where HeaderID = '" & HeaderID & "'" 'Open RecordSet With rst1 .ActiveConnection = cnn1 .Open(Str1, , _ ADODB.CursorTypeEnum.adOpenKeyset, _ ADODB.LockTypeEnum.adLockOptimistic) End With Previously, I used the same code, however, the SQL string was slightly different. I checked the JobName field in the Where statement. And everything worked fine. But when I change the Where statement to check the primary key of the table HeaderID (an autonumber field). I got this error... An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in ServiceEstimateApp.exe Additional information: Data type mismatch in criteria expression. ..pointing at the .Open(Str.... portion of the code. Any ideas on what might be wrong? Thank you! Quote
Moderators Robby Posted April 18, 2003 Moderators Posted April 18, 2003 When using numeric values don't use the single quotes... Dim Str1 As String = "Select * from EstHeader Where HeaderID = " & HeaderID Quote Visit...Bassic Software
MarkItZero Posted April 18, 2003 Author Posted April 18, 2003 Its always something simple Thank You Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.