c# - 为什么.NET 两次添加 SP 参数?
问题描述
我有一个 winforms 应用程序,当我插入一行时我正在调用一个 SP。我正在定义参数,但它在最后添加了额外的参数。
da.InsertCommand = new SqlCommand("dbo.GridInsert", new SqlConnection(MC.ConnectionString));
da.InsertCommand.CommandType = CommandType.StoredProcedure;
da.InsertCommand.Parameters.Add("@ApplyTo", SqlDbType.VarChar, 25).Value = applyTo;
da.InsertCommand.Parameters.Add("@ApplyType", SqlDbType.VarChar, 50).Value = applyType;
da.InsertCommand.Parameters.Add("@ApplyValue", SqlDbType.VarChar, 50).Value = applyValue;
da.InsertCommand.Parameters.Add("@ID", SqlDbType.BigInt, 0, "ID");
da.InsertCommand.Parameters.Add("@InstanceID", SqlDbType.BigInt, 0, "InstanceID");
上面,第一个 3 参数从变量中获取它们的值。接下来的 2 个与网格列相关联。但是,这是发送到数据库的内容。
exec dbo.GridInsert @ApplyTo='xxx',@ApplyType='xxx',@ApplyValue='xxx',@ID=NULL,@InstanceID=38,@ApplyTo='xxx',@ApplyType='xxx',@ApplyValue='xxx'
请注意,第一个 3 参数放在前面和末尾。另外,如果我不将这 3 个参数添加到集合中,它们无论如何都会放在最后。有人有任何线索吗?
解决方案
推荐阅读
- c# - 围绕鼠标点缩放自绘窗口
- python - Marshmallow_MongoEngine:ModuleNotFoundError:没有名为“marshmallow.compat”的模块
- arrays - 雄辩的 where 子句不采用关联数组
- android - (React-Native 0.62.0)无法找到项目的匹配变体:react-native-community_async-storage(其他库也一样)
- javascript - LitElement - 如果值为 false,则不要添加属性
- r - 在 R 中对多个条件使用 rle() 函数
- java - Java Spark Map 错误:错误执行程序:阶段 0.0 spark scala 中的任务 0.0 异常?
- r - 在 R 的上下文中,波浪号是什么?
- java - 片段在活动上重叠
- serverless-framework - 保留超过五个版本的服务器少包回滚到?