Solved

Too few parameters

Posted on 2004-04-07
10
346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
ID: 10774048
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
ID: 10774054
i.e. shouldn't it probably be

isReordered

?
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10774103
Sure
           where items.ItemID = ID496

is right?

Shouldn't that be
           where items.ItemID = 496
or
           Where items.ItemID = 'ID496'
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 37

Expert Comment

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

Author Comment

by:mattdye
ID: 10774119
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 10774128
statement.setNull(1);
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10774136
(where 'statement' is a PreparedStatement)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10774176
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10774192
>> 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
ID: 10774210
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] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

632 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