I have a button in a form that I want to execute a simple stored procedure to insert a single value into a database table.
The Stored Procedure is:
=================
CREATE PROCEDURE bplog_insert_invoice_detail (@.invo_Id Int) AS
INSERT INTO Invoice_Detail
(Invo_Id)
VALUES(@.Invo_Id)
GO
=================
How do i pass the value from and text field (@.invo_id) and execute the stored procedure when a button is clicked.
Regards.
This is untested, but it should work:
SqlConnection cn = new SqlConnection(connectionString);
SqlComment cmd = cn.CreateCommand();
cmd.CommandText = "bplog_insert_invoice_detail";
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter parm = new SqlParameter("@.invo_Id", SqlDbType.Int)
parm.Value = parameterValue;
cmd.Parameters.Add(parm);
cmd.ExecuteNonQuery();
Hope that helps.
No comments:
Post a Comment