无法将参数值从 SqlParameter 转换为字符串 [英] Failed to convert parameter value from a SqlParameter to a String
本文介绍了无法将参数值从 SqlParameter 转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经阅读了所有以前的类似问题,但无法使其正常工作
hi I have read all the previous similar issues but cant get it working
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@Lot", SqlDbType.NChar, 112);
param[0].Value = "Bob123457";
DataSet ds1 = db.ExecuteDataSet("Getmagesbylot2", param );
我的存储过程正在寻找一个 nchar (112) 作为参数我试过带引号和不带引号以及带单引号
my stored procedure is looking for a nchar (112) as a paramater i've tried with and without quotes and with single quotes
推荐答案
ExecuteDataSet 调用采用实际参数值,而不是 SqlParameter
对象.将其更改为简单地执行:
The ExecuteDataSet call takes the actual parameter values, not SqlParameter
objects. Change it to simply do:
var ds1 = db.ExecuteDataSet("Getmagesbylot2", "Bob123457");
您可能还想检查 SP 是否拼写正确,也许应该是 GetImagesByLot2
.
You might also want to check that you've spelled the SP correctly, maybe it should be GetImagesByLot2
.
这篇关于无法将参数值从 SqlParameter 转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文