• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 356
  • Last Modified:

Too few parameters

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
mattdye
Asked:
mattdye
  • 5
  • 4
1 Solution
 
CEHJCommented:
Surely that should be

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

?

and is there a typo here?

>>sRedordered<<

0
 
CEHJCommented:
i.e. shouldn't it probably be

isReordered

?
0
 
zzynxSoftware engineerCommented:
Sure
           where items.ItemID = ID496

is right?

Shouldn't that be
           where items.ItemID = 496
or
           Where items.ItemID = 'ID496'
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
zzynxSoftware engineerCommented:
Just as small remark: Why use a string field to express a boolean?  (cf. isRedordered = 'false')
0
 
mattdyeAuthor Commented:
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
 
CEHJCommented:
statement.setNull(1);
0
 
CEHJCommented:
(where 'statement' is a PreparedStatement)
0
 
zzynxSoftware engineerCommented:
>> 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
 
zzynxSoftware engineerCommented:
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

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now