When i click the Save Button in my page, it executes this
protected void btnsave_Click(object sender, EventArgs e)
and then it calls save() function.
In save() function it calls stored procedure insertcustrec5. As soon as it reaches to the stored procedure insertcustrec5, it raises error
“Procedure or function ‘insertcustrec5’ expects parameter ‘@tb1’,
which was not supplied”
but i supplied..n i checked every parameter getting its value still this error keeps on occurring.
–> My Stored Procedure is:
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)
–> Save Function which calls Stored procedure is:
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 Function:-
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();
}
}
–> Save Button Click:-
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();
}
Write while adding parameters to sp
instead of