create procedure p
(
@firsttno int,
@secondno int,
@operation varchar(max),
@result int,
@optime datetime
)
as begin
Insert into table1(firstno,secondno,operation,result,optime) Values(@firsttno,@secondno,@operation,@result,@optime)
end
In C# code
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "p";
cmd.Parameters.AddWithValue("@firsttno", TextBox1.Text);
cmd.Parameters.AddWithValue("@secondno", TextBox2.Text);
cmd.Parameters.AddWithValue("@operation", DropDownList1.SelectedValue);
cmd.Parameters.AddWithValue("@result", Label1.Text);
cmd.Parameters.AddWithValue("@optime", dat.Text);
cmd.Connection = con;
cmd.ExecuteNonQuery();