过程或函数 [sproc_name] 需要参数“@materials”,但未提供该参数
这让我发疯;)
我有这个存储过程...
ALTER PROCEDURE [dbo].[sproc_FindFoundries]
(@materials varchar(1000),
@capabilities varchar(1000))
AS
BEGIN
/* insert SQL code here */
END
该过程接受两个逗号分隔的字符串。在我的应用程序中,我有以下代码。
BCDataContext db = new BCDataContext();
SqlParameter prmMaterials = new SqlParameter("materials", SqlDbType.VarChar, 1000);
prmMaterials.Value = materialList;
SqlParameter prmCapability = new SqlParameter("capabilities", SqlDbType.VarChar, 1000);
prmCapability.Value = capabilityList;
SqlConnection cn = new SqlConnection(db.Connection.ConnectionString);
SqlCommand cmd = new SqlCommand("sproc_FindFoundries", cn);
cmd.Parameters.Add(prmMaterials);
cmd.Parameters.Add(prmCapability);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
当我执行代码时,出现错误
过程或函数 [sproc_name] 需要参数“@materials”,但未提供该参数。
当我尝试填充数据集时。测试时我已验证这两个参数都包含数据且不为空。有什么我错过的吗?如果有第二双眼睛,我们将不胜感激。
谢谢。
This is driving me nuts ;)
I have this stored procedure ...
ALTER PROCEDURE [dbo].[sproc_FindFoundries]
(@materials varchar(1000),
@capabilities varchar(1000))
AS
BEGIN
/* insert SQL code here */
END
The procedure accepts two comma delimited strings. In my application I have the following code.
BCDataContext db = new BCDataContext();
SqlParameter prmMaterials = new SqlParameter("materials", SqlDbType.VarChar, 1000);
prmMaterials.Value = materialList;
SqlParameter prmCapability = new SqlParameter("capabilities", SqlDbType.VarChar, 1000);
prmCapability.Value = capabilityList;
SqlConnection cn = new SqlConnection(db.Connection.ConnectionString);
SqlCommand cmd = new SqlCommand("sproc_FindFoundries", cn);
cmd.Parameters.Add(prmMaterials);
cmd.Parameters.Add(prmCapability);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
When I execute the code, I get the error
Procedure or function [sproc_name] expects parameter '@materials', which was not supplied.
when I try fill the dataset. When testing I have verified that both parameters contain data and are not null. Is there something I've missed? A second pair of eyes would be greatly appreciated.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用
@materials
、@capability
作为参数名称:Use
@materials
,@capabilities
as parameters' name:命名参数时需要添加@
When naming your parameters you need to put the @ in
您将参数称为“材料”和“功能”,而不是“@材料”和“@功能”
You are calling your parameters "materials" and "capabilities" instead of "@materials" and "@capabilities"
我这样尝试,它对我有用:
我的程序是这样的:
I tried like this, Its worked for me:
My procedure is like this: