If I add unnamed parameters to my SqlCommand
, how do I set the parameter values, on the SqlCommand?
I have no problems when I use named parameters, where I can just do SqlCommand.Parameters.AddWithValue()
.
Example:
Select * from sometable where SomeValue=? and AnotherValue=?
With ADO.NET against SQL Server, you cannot use those ?
for parameters - you always have to use @paramName
approach.
The ?
for unnamed parameters is an ODBC "left-over" but not supported in ADO.NET when using SQL Server (not sure about MS-Access)
Use ADODBConnection and ADODBCommand instead of SQL versions.