Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Must Declare Scalar Variable run time error
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01472783
Message ID:
01472817
Views:
31
Hi Viv. Thanks for reply.
I tried without the parameters and it worked fine.
Also, I changed the driver from OleDB to Sql and that worked fine with the parameters...dont know why I initially had it as OLEDB

Regards,
Gerard



>>Hi.
>>I am getting a run time error with tthe following code:(Must declare scalarVariable "@TranType")
>>
>>string table;
>>table ="MyTable";
>>
>>string txtUpdate = "Update " + table + " SET FIELD1=FIELD2 WHERE TRANTYPE = @TranType";
>>OleDbCommand sqlUpdate = new OleDbCommand(txtUpdate, dbConn);
>>sqlUpdate.Parameters.Add("@TranType", OleDbType.VarWChar, 10);
>>sqlUpdate.Parameters["@TranType"].Value = "INVOICE";
>>sqlUpdate.ExecuteNonQuery();
>
>I don't think the Oledb provider supports named parameters. Try:
string txtUpdate = "Update " + table + " SET FIELD1=FIELD2 WHERE TRANTYPE = ?";
Previous
Reply
Map
View

Click here to load this message in the networking platform