Too Few Parameters Expected 1

G

Guest

Hi,

I'm doing an assignment getting a java program to talk to a MS Access 2003
database. In my java application I have the following statements:

String query = "Delete from Session_Enrolment Where emp_id = '" + empId +
"'" + " AND session_id = '" + aSessionId + "'";

statement.executeUpdate(query);

However when I run the application I get the error "Too few parameters -
Expected 1"

How do I solve this?
I NEED HELP PLZ!!!!

Thanks.
Simon
 
K

Ken Snell [MVP]

The SQL statement needs to tell the database engine the "fields" being
deleted:
"DELETE * FROM ....etc."

Also, are emp_id and session_id both text fields? Your syntax assumes that
they are, as you are delimiting the values from the variables with '
characters.
 
D

Dirk Goldgar

Ken Snell said:
The SQL statement needs to tell the database engine the "fields" being
deleted:
"DELETE * FROM ....etc."

Actually, I don't believe that's necessary. The "DELETE FROM
Also, are emp_id and session_id both text fields? Your syntax assumes
that they are, as you are delimiting the values from the variables
with ' characters.

Simon - another thing to check is that both of these field names are
spelled correctly. If Jet doesn't recognize a name, it assumes it's a
parameter.
 
K

Ken Snell [MVP]

Dirk Goldgar said:
Actually, I don't believe that's necessary. The "DELETE FROM
<tablename>" syntax is acceptable, though the graphical query designer
won't let you build it.

Thanks, Dirk.... hadn't tried that "shorter" version before.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top