C# 过程或函数“insertcustrec5”需要未提供的参数“@tb1”
当我单击页面中的Save按钮时,它会执行此操作C# 过程或函数“insertcustrec5”需要未提供的参数“@tb1”,c#,.net,C#,.net,当我单击页面中的Save按钮时,它会执行此操作 protected void btnsave_Click(object sender, EventArgs e) 然后调用save函数。 在save函数中,它调用存储过程insertcustrec5。一旦到达存储过程insertcustrec5,就会引发错误 过程或函数“insertcustrec5”需要参数“@tb1”, 这是没有提供的 但是我提供了..n我检查了每个参数,得到了它的值,但这个错误仍然不断发生 ->我的存储过程是: ALTER
protected void btnsave_Click(object sender, EventArgs e)
然后调用save函数。
在save函数中,它调用存储过程insertcustrec5。一旦到达存储过程insertcustrec5,就会引发错误
过程或函数“insertcustrec5”需要参数“@tb1”,
这是没有提供的
但是我提供了..n我检查了每个参数,得到了它的值,但这个错误仍然不断发生
->我的存储过程是:
ALTER procedure [dbo].[insertcustrec5]
(
@RID int,
@Remarks varchar(MAX),
@CRDate date,
@ChallanNo float,
@Quantity float,
@tb1 int,
@Amount float
)
As
INSERT INTO Customer_Receive(ChallanNo, CRDate, RID, Quantity, Remarks,CustID,Amount)
VALUES (@ChallanNo,@CRDate,@RID,@Quantity,@Remarks,@tb1,@Amount)
public void save()
{
data.AddParameter("RID", this.rid);
data.AddParameter("CustID", this.tb1);
data.AddParameter("Remarks", this.remarks);
data.AddParameter("CRDate", this.CRDate);
data.AddParameter("ChallanNo", this.ChallanNo);
data.AddParameter("Quantity", this.quantity);
data.ExecuteNonQuery("insertcustrec5");
->调用存储过程的Save函数是:
ALTER procedure [dbo].[insertcustrec5]
(
@RID int,
@Remarks varchar(MAX),
@CRDate date,
@ChallanNo float,
@Quantity float,
@tb1 int,
@Amount float
)
As
INSERT INTO Customer_Receive(ChallanNo, CRDate, RID, Quantity, Remarks,CustID,Amount)
VALUES (@ChallanNo,@CRDate,@RID,@Quantity,@Remarks,@tb1,@Amount)
public void save()
{
data.AddParameter("RID", this.rid);
data.AddParameter("CustID", this.tb1);
data.AddParameter("Remarks", this.remarks);
data.AddParameter("CRDate", this.CRDate);
data.AddParameter("ChallanNo", this.ChallanNo);
data.AddParameter("Quantity", this.quantity);
data.ExecuteNonQuery("insertcustrec5");
->执行查询功能:-
public int ExecuteNonQuery(string commandText)
{
try
{
SqlCommand command = new SqlCommand(commandText);
command.CommandType = System.Data.CommandType.StoredProcedure;
this.OpenConnection();
command.Connection = this.connection;
command.Parameters.AddRange(cmdParams.ToArray());
return command.ExecuteNonQuery();
}
finally
{
this.CloseConnection();
}
}
->保存按钮单击:-
protected void btnsave_Click(object sender, EventArgs e)
{
bllCustomer_Receive receive = new bllCustomer_Receive();
string datetime = txtcrdate.Text;
DateTime dt = DateTime.ParseExact(datetime, "d/M/yyyy", null);
receive.CRDate = dt;
receive.ChallanNo = txtchallan.Text;
receive.rid = txtrid.Text;
receive.quantity = float.Parse(txtquantity.Text);
receive.remarks = txtremarks.Text;
tb1.Text = Convert.ToString(drpdwncustID.SelectedItem);
receive.tb1 = tb1.Text;
receive.save();
}
好的,您没有提供@tb1参数,正如代码的以下部分中所述的错误:
data.AddParameter("RID", this.rid);
data.AddParameter("CustID", this.tb1);
data.AddParameter("Remarks", this.remarks);
data.AddParameter("CRDate", this.CRDate);
data.AddParameter("ChallanNo", this.ChallanNo);
data.AddParameter("Quantity", this.quantity);
data.ExecuteNonQuery("insertcustrec5");
同时,您还应该添加一行来添加@amount参数…在向sp添加参数时写入
data.AddParameter("tb1", this.tb1);
而不是
data.AddParameter("CustID", this.tb1);
你没有提供。你有没有读过你发布的代码?注意:当你为tb1修复这个问题时,你会在数量上遇到类似的问题…但是我提供了..n我检查了每个参数,得到了它的值,但这个错误仍然不断发生。事实并非如此。您没有提供参数或没有向我们显示真实代码。