Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data type mismatch in criteria expression.

Status
Not open for further replies.

DMG2000

Programmer
Aug 13, 2000
52
US
Everytime I try to call, or add to a primary key with a database, I get this error &quot; Data type mismatch in criteria expression.&quot;, I know it has to be possible to get or update the primary key autonumber, but why isn't this working?<br>Code as follows:<br>sql= &quot;insert into orderitems (<b>orderid</b>,productid, qty,priceperunit) values ('&quot; & <b>orderid</b> & &quot;','&quot; & acart(i,0) & &quot;','&quot; & acart(i,1) & &quot;','&quot; & rsprice(&quot;saleprice&quot;) & &quot;')&quot;<br><br>Note: Bold is the primary key<br><br>Appreciate any thoughts!
 
Dear DMG2000,

When you have database level errors, take your SQL Statement into your database query execution environment and run it there. The database query tool should provide you with detailed information regarding the problem with the SQL Statement.

In this case if you are dealing with Access Autonumber or SQL Server IDENTITY columns. You are not allowed to set those column values during a row insert operation. The engine is supposed to provide that value for you, that is the whole point of those column types.

Hope this helps
-pete
 
Thanks Pete. I figured out what the error was. I was using adOpenDynamic when I should have been using adOpenKeyset...took long enough but after looking at the code for hours, it came to me.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top