Solved

Too few parameters

Posted on 2004-04-07
10
340 Views
Last Modified: 2010-03-31
Hey guys, im trying to run an update statement in java, my insert statement works fine...  below is the error im getting:

UPDATE Items set stockLevel = '99', isRedordered = 'false' Where items.ItemID = ID496; <-- values
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2



code: .....

String token = st.nextToken(); //Start the SQL statement
      SQLString = "UPDATE Items set stockLevel = '"; //First cell a string so has ' on either side of sql
      SQLString +=token + "',"; // data stock level


        token = st.nextToken(); // Read is third token
      SQLString +=" isRedordered = '" +token+"' Where ItemID = ";      //ordered?

     
        token = st.nextToken(); // Read is second token
      SQLString +="'" +token + "'";      //id

      SQLString +=";";      //end cell end with a bracket as it the last cell

0
Comment
Question by:mattdye
  • 5
  • 4
10 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
Comment Utility
Surely that should be

UPDATE Items set stockLevel = '99', isRedordered = 'false' Where items.ItemID = 'ID496'

?

and is there a typo here?

>>sRedordered<<

0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
i.e. shouldn't it probably be

isReordered

?
0
 
LVL 37

Expert Comment

by:zzynx
Comment Utility
Sure
           where items.ItemID = ID496

is right?

Shouldn't that be
           where items.ItemID = 496
or
           Where items.ItemID = 'ID496'
0
 
LVL 37

Expert Comment

by:zzynx
Comment Utility
Just as small remark: Why use a string field to express a boolean?  (cf. isRedordered = 'false')
0
 

Author Comment

by:mattdye
Comment Utility
ok ok fair play, dont suppose u can help me with another prob... how can i enter a null for a date datatype in access, ive tried null but doesnt work
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
statement.setNull(1);
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
(where 'statement' is a PreparedStatement)
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
0
 
LVL 37

Expert Comment

by:zzynx
Comment Utility
>> how can i enter a null for a date datatype in access
Doesn't  

            UPDATE Items set stockLevel = '99', isRedordered = 'false', myDate = NULL where ....

work, then?
0
 
LVL 37

Expert Comment

by:zzynx
Comment Utility
Hey, hey, that's a quicky.
What was the solution now?

Did
       items.ItemID = 'ID496'

generate the error?
What about your null value then?
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Passing list of object to Oracle Database Procedure 3 40
strCount chalenge 3 50
wordappend challenge 8 82
solarwind tftp server 2 30
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now