Search code examples
c#asp.net.netsqlparameter

Adding SQL Parameters in C#


What is the difference between:

myCommand.Parameters.AddWithValue("search", "% " + myValue + " %");

and:

myCommand.Parameters.AddWithValue("@search", "% " + myValue + " %");

The difference above is with and without the @ symbol. Does it do anything special?


Solution

  • You need to use the variant with the '@'. The '@' symbol signifies a variable or a stored procedure / function parameter.