我在这里阅读了MSDN文档和示例,我知道Paramters.Add调用的正确语法是:
command.Parameters.Add("@ID", SqlDbType.Int);
command.Parameters["@ID"].Value = customerID;
Run Code Online (Sandbox Code Playgroud)
您必须在其中指定参数名称,SqlDbTypeAND与值.Value.
现在,Parameters.AddWithValue调用的正确语法是:
command.Parameters.AddWithValue("@demographics", demoXml);
Run Code Online (Sandbox Code Playgroud)
单行并跳过该Type部分.
我的问题是:当我这样做时,怎么样?
command.Parameters.Add("@demographics", demoXml);
// .Add method with .AddWithValue syntax
Run Code Online (Sandbox Code Playgroud)
我没有得到任何编译错误甚至更奇怪,一切似乎在代码执行时正常工作?