我应该包括@时使用SqlCommand.Parameters.AddWithValue? [英] should I include the @ when using SqlCommand.Parameters.AddWithValue?
本文介绍了我应该包括@时使用SqlCommand.Parameters.AddWithValue?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在使用AddWithValue时,我始终在参数名称中包含at符号,但我只是注意到某些由不使用它的人编写的代码。一种方式比另一种方式更正确?
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);
或
cmd.Parameters.AddWithValue("@ixCustomer", ixCustomer);
推荐答案
否,两者都是等效的。我个人倾向于使用带有 @
符号的符号,以便与用于存储过程的T-SQL代码一致。
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.
但是据我所知,这两种方法都适用于与SQL Server交互的.NET应用程序。
But as far as I know, both methods are fine for .NET apps interfacing with SQL Server.
这篇关于我应该包括@时使用SqlCommand.Parameters.AddWithValue?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文