Should I include @ when using SqlCommand.Parameters.AddWithValue?

I always included the at sign in the parameter name when using AddWithValue, but I only noticed code written by someone else that didn't use it. Is one way more correct than the other?

cmd.Parameters.AddWithValue("ixCustomer", ixCustomer); 

or

 cmd.Parameters.AddWithValue("@ixCustomer", ixCustomer); 
+6
c # database parameters
source share
1 answer

No, both are equivalent at the end. I personally prefer to use the notation with the @ icon itself to match the T-SQL code for the saved proc file that I am writing.

But as far as I know, both methods are great for .NET applications that interact with SQL Server.

+5
source share

All Articles