【发布时间】:2013-04-07 23:57:00
【问题描述】:
我正在开发一个将执行存储过程的按钮。返回数据时,我只需要将记录号传递到稍后将用于后页的数组中。然后,aspx 的后台会将记录号输入到字符串中,并将用户重定向到 RecordInfo 页面。这是我到目前为止的内容,但我一直收到同样的错误:
{“此 SqlParameterCollection 不包含参数名称为 '@RecNum_OUT' 的 SqlParameter。”}
希望你能帮助我。
<asp:Button ID="GetNextRec" runat="server" Text="Get Part"
onclick="GetNextRec_Click" OnCommand="btnNext_OnClick" />
ASPX.CS
protected void GetNextRec_Click(object sender, EventArgs e)
{
String[] q = new String[1];
q = Record.GetNextRec();
Response.Redirect("~/PartsRecord.aspx?mode=full&queue=" + q[0], false);
}
数据库cs
public static String[] GetNextRec()
{
Database db = DataFactory.CreateDatabase();
DbCommand dbc = db.GetProc("GetNextRec");
db.ExecuteNonQuery(dbc); // IDK if this si doing anything
String[] q = new string[1];
q[0] = dbc.Parameters["@RecNum_OUT"].Value.ToString(); // "An SqlParameter with ParameterName '@requisition_OUT' is not contained by this SqlParameterCollection."}
return q;
}
【问题讨论】:
-
I want to just let the stored procedure gather the data needed and return the part info into the datagrid.,这到底是什么意思? -
我的意思是存储过程已经设置为获取我想要检索的数据。然后需要将该数据插入到数据网格中
-
你有什么问题?你有例外吗?
-
这是弹出的错误:Procedure GetNextRec has no parameters and arguments were provided
-
我相信你正在寻找这样的东西stackoverflow.com/questions/101033/…
标签: c# sql stored-procedures parameter-passing