4

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=?
1
  • Ugh, that is unfortunate. I guess I'll have to name them, then. You should make an answer :) Commented Jan 18, 2012 at 11:52

2 Answers 2

4

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)

Sign up to request clarification or add additional context in comments.

Comments

0

Use ADODBConnection and ADODBCommand instead of SQL versions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.