• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error Setting parameters in a Update preparedstatments

Tom Schindler
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys I have been working on making a form that updates a Microsoft Access database and I cannot seem to figure out the root of this error I continue to receive.

My edit form upon loading displays the information for a selected item. There is a submit button that updates the database with all changes. I have been using preparedStatements to update my database and I have 8 parameters for my first command, however, only 3 of the parameters are recognized. I have checked the SQL statement repeatedly in Access and have determined that it is not the cause.

My code goes as follows:

preparedStatement contactUpdate = "Update tblContact Set FirstName = '?', LastName = '?', Suffix= '?', DOB = '?',Address = ?...(other inserts)... Where contactID = ?";

//Error right here on the next line.
contactUpdate.setInt(5, 32);
contactUpdate.setString(8, 1);


If you have any suggestions please let me know.

Jeanne Boyarsky
author & internet detective
Posts: 36032
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

I may be missing the obvious here, but what error message do you get?

Does it work if you hardcode "address = 1" instead of using the prepared statement? This will tell you if the error is in the SQL part or the prepared statement part. Which will help someone here give you more specific advice.
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!