Data type mismatch MS Access autonumber field
Hi, im trying to delete a rec from Access from java code.
My SQL is: String query = "Delete from items where item_id='"+dbitem_id+"'";
Where dbitem_id is a Double variable.
Item_id in Access is a autonumber longinteger
Im getting [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression. when I run it.
Any idea how I can fix this?
thanks.
Jason
# 1
String query = "Delete from items where item_id=' "+dbitem_id+" ' ";
I've never used MS Access but if this were a proper database I would say you have a quote problem:
Single quotes are used wrap strings like " in java.
Personally I never use Statements only PreparedStatements it makes the code much more readable and I find it a better practice as using statements often introduces database specifics.
# 2
Hi, many thanks for the reply, your suggestion fixed the problem and helped me move on.Im stuck with Access for the moment but I hope to move it over to MySQL if I get the time as thats is a better database.Jason.