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

£可爱£侵袭症+ 提交于 2019-12-10 12:55:43

问题


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 more correct than the other?

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

or

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

回答1:


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.



来源:https://stackoverflow.com/questions/2313540/should-i-include-the-when-using-sqlcommand-parameters-addwithvalue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!