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

[423 byte] By [deaconj1234a] at [2007-11-27 4:32:45]
# 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.

ChristopherAngela at 2007-7-12 9:42:29 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 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.
deaconj1234a at 2007-7-12 9:42:29 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...