SQL Exception: Too few parameters.....

A

Aaron B.

I am experienceing a problem that was already brought up on this group
five years ago, see http://groups.google.com/groups?hl=...l=en&lr=&q=author:pranubha%40comp.nus.edu.sg+
To repeat, the problem is as follows. As I'm trying to execute a
perfect SQL query thru my java program, I get an SQLException, saying:
"Too few parameters. Expected 2", or sometimes "Expected 1". Someone
back then suggests to use PreparedStatements instead of normal
queries. What is that? I need someone to explain it to me. Thanks a
lot!

Aaron B.
 
T

thirdrock

Aaron said:
As I'm trying to execute a
perfect SQL query thru my java program, I get an SQLException, saying:
"Too few parameters. Expected 2", or sometimes "Expected 1".
What is happening is that the SQL server is expecting some parameters
for your query, and you are not providing them.
Someone
back then suggests to use PreparedStatements instead of normal
queries. What is that? I need someone to explain it to me. Thanks a
lot!

You don't have a help file?

If you were using the mySQL odbc driver, you would find some sample code
in the documentation that would answer your question, but as you haven't
even provided information on which sql server you are using, you might
find help not forthcoming.

Ian
 
E

Erich Reimberg N.

Aaron,

It happened to me when the query has mispelled column names. When that
happens, SQL Server tries to use those mispelled names as parameters, and
it expects that you previously define those parametes.

Erich
 

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

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top