开发者

should I include the @ when using SqlCommand.Parameters.AddWithValue?

开发者 https://www.devze.com 2022-12-21 09:15 出处:网络
I have always included the at sign in the parameter name when using AddWithValue, but I just noticed some code written by someone else that doesn\'t use it. Is one way mor开发者_运维问答e correct than

I have always included the at sign in the parameter name when using AddWithValue, but I just noticed some code written by someone else that doesn't use it. Is one way mor开发者_运维问答e correct than the other?

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

or

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


No, both are equivalent in the end. I personally tend to use the notation with the @ sign myself, to be consistent with the T-SQL code for stored proc I write.

But as far as I know, both methods are fine for .NET apps interfacing with SQL Server.

0

精彩评论

暂无评论...
验证码 换一张
取 消