| Author |
Topic |
|
rameshkg
Starting Member
22 Posts |
Posted - 2004-06-18 : 10:56:44
|
| Hi,I am using an UPDATE prepared statement to update a table of SQL Server 2000. I am using parameters in the UPDATE statement and these parameters will be passed with values at runtime. The error i am getting, BEFORE I PASS VALUES TO THE PARAMETERS is as follows :W 5296 (java_extensions.cxx:956): Session.checkConnection(): Microsoft SQLServer error message: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax errorThe Prepared Statement which i am using is as follows :Update TEMP set X_1 = ?, Y_1 = ?, Z_1 = ?, W_1 = ? where X_1 = ?Any idea as to what is the problem ? Is it because of underscores in column names OR because of '?' as parameter indicators ?I verified the column names, syntax etc., everything is OK.Your early input is appreciated.ThanksRamesh |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2004-06-18 : 11:08:27
|
| maybe?? => @X_1Corey |
 |
|
|
rameshkg
Starting Member
22 Posts |
Posted - 2004-06-18 : 11:19:28
|
| Thanks for the quick reply.Sorry... i didn't get you...Do you want me to replace only for the WHERE clause as @X_1 instead of X_1=?.What about other parameters specified for X_1, Y_1 etc., ? |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2004-06-18 : 11:30:28
|
| Sorry... something like this?Update TEMP set X_1 = @newX_1, Y_1 = @Y_1, Z_1 = @Z_1, W_1 = @W_1 where X_1 = @X_1Corey |
 |
|
|
rameshkg
Starting Member
22 Posts |
Posted - 2004-06-18 : 11:36:32
|
| Thanks corey, i will try that...What about INSERT statements ? Can i use in the same way, like INSERT INTO TEMP (X_1,Y_1,Z_1,W_1) values(@X_1,@Y_1,@Z_1,@W_1).Also, from this we can infer that, in SQL Server, we have to use @<col name> to pass parameters instead of '?'. Hope i am correct. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-06-18 : 11:40:42
|
| @ is used to identify a local variableColumn names are simply thatAnd an UPDATE and An INSERT are two different oprationsDo you have SQL Server Client tools installed?Do you know what Enterprise Manager, Query Analyzer, and Books Online are?Brett8-) |
 |
|
|
rameshkg
Starting Member
22 Posts |
Posted - 2004-06-18 : 11:46:48
|
| Yes , i know Query Analyzer eventhough i don't know how to use it. My collegue tried using ? as parameter in query analyzer. It gave the above error message, naturally, since, i think we can't execute the prepared statement, just like that, without executing through a client like ASP etc.,My requirement is to use both UPDATE and INSERT statements using prepared statement and by passing parameters to both of them. |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2004-06-18 : 12:53:17
|
| quick examples:Declare @var1 int,@var2 nvarchar(10)Set @var1 = 5Set @var2 = 'pizza'Update yourTableSetcol1 = @var1,col2 = @var2Set @var1 = 7Set @var2 = 'beer'Insert Into your tableSelect col1 = @col1,col2 = @var2In ASP:sqlstr = "Update yourTable Set col1=" & var1 & ", col2='" & var2 & "' where col1=<condition>"Corey |
 |
|
|
|