Why does SqlParametersCollection require "@" at the beginning of the parameter name every time?

Well, the title of the question is pretty much the question itself, so why would I have to write "@" every time before the sql parameter name like this?

command.Parameters.AddWithValue("@CustomerID", this.CustomerId);

      

I know this is how parameters are declared with SQL, but shouldn't that be handled by the framework as it always does?

+3


source to share


2 answers


I am assuming you are using Microsoft SQL Server. MS SQL names its variables this way and therefore need to be named as well.



+1


source


Variable names in MS SQL Server must start with the at sign (@). See How To Declare Variables in SQL for more information.



+1


source







All Articles