-4

私のページで保存ボタンをクリックすると、これが実行されます

protected void btnsave_Click(object sender, EventArgs e)

そして、save()関数を呼び出します。関数では、save()ストアド プロシージャ insertcustrec5 を呼び出します。ストアド プロシージャ insertcustrec5 に到達するとすぐにエラーが発生します

「プロシージャまたは関数 'insertcustrec5' は、指定されていないパラメーター '@tb1' を予期しています」

しかし、私は提供しました..niはすべてのパラメータをチェックしてその値を取得しましたが、それでもこのエラーは発生し続けます。

--> 私のストアド プロシージャは次のとおりです。

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");

--> ExecuteNonQuerry 関数:-

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();
    }
4

2 に答える 2

5

@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ます...

于 2012-05-21T13:27:00.317 に答える
1

spにパラメータを追加しながら書き込みます

data.AddParameter("tb1", this.tb1);

それ以外の

 data.AddParameter("CustID", this.tb1);
于 2012-05-21T13:32:36.137 に答える