微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – SqlCommand的输入参数

我有sqlCommand的以下参数.如何使其存入和存储存储过程的参数值.
sqlCommand MysqLCommand = new sqlCommand("aspInsertZipCode",MysqLConnection);
 MysqLCommand.CommandType = CommandType.StoredProcedure;
 MysqLCommand.Parameters.Add("@DaTarows",dataStringToProcess.ToString());

解决方法

var pInOut = MysqLCommand.Parameters.Add("@DaTarows",dataStringToProcess.ToString());
pInOut.Direction = ParameterDirection.InputOutput;

然后在执行命令后读取输出值:

// assumes that the parameter is a string and that it Could possibly be null
string value = Convert.Isdbnull(pInOut.Value) ? null : (string)pInOut.Value;

原文地址:https://www.jb51.cc/csharp/92954.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐