Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

USing JAVA to manipulate Access DB 1

Status
Not open for further replies.

BigAl1520

Technical User
Mar 12, 2008
2
US
I am using JAVA JDK 5 to manipulate an Access 2003 database. The below UPDATE statement produces the error below:

"UPDATE [*Server times] SET [*Server times].[Tsf P1] = ? WHERE [Object type] = "+valuesCurrent[0]+" AND [SRAN ID] = "+valuesCurrent[1]+" AND [SERVER TYPE]= "+valuesCurrent[2];

here is the error:

“[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.”

If I drop one of the criteria the statement does not produce an error, but it does not update the database correctly because one of the criteria was not enforced, for example:

"UPDATE [*Server times] SET [*Server times].[Tsf P1] = ? WHERE [Object type] = "+valuesCurrent[0]+" AND [SRAN ID] = "+valuesCurrent[1];

I checked to make sure that the spelling of the tables are correct, in fact it does not matter which of the three criteria is removed, it still works.


Any ideas?

Thanks in advanced.

 
ok, are ObjectType, SRAN ID and SERVER TYPE all numerical fields in the table? If they are strings they need to be quoted:

Code:
"UPDATE [*Server times] SET [*Server times].[Tsf P1] = ? WHERE [Object type] = [COLOR=red]'[/color]"+valuesCurrent[i][0]+"[COLOR=red]'[/color] AND [SRAN ID] = "+valuesCurrent[i][1]+" AND [SERVER TYPE]= "+valuesCurrent[i][2];


Leslie

In an open world there's no need for windows and gates
 
Leslie,

SERVER TYPE is a string so I modified the code this way as you indicated:

"UPDATE [*Server times] SET [*Server times].[Tsf P1] = ? WHERE [Object type] = "+valuesCurrent[0]+" AND [SERVER TYPE]= '"+valuesCurrent[2]+"' AND [SRAN ID] = "+valuesCurrent[1];

Now it works perfectly, I do not how to tell you how much I appreciate your help, thanks a million!

Al

By the way, how do you get your code inside that fancy box labeled CODE within your reply?
 
To get this
Code:
my code here
type this
[ignore]
Code:
my code here
[/ignore]
 
Thanks Joe! Glad to help, Al!

Have a great day!

Leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top