Hi,
you can try some thing like this
create procedure insert_data
(
@Id int, @Name Varchar(20) , @address varchar(50)
)
begin
Insert into table1(Id,Name,address) values(@Id,@Name,@address)
end
you can use the following c# code on button click to insert data
try
{
sqlConnection con = new SqlConnection(dbConnectionString);
SqlCommand comm= new SqlCommand("insert_data", con);
comm.CommandType = CommandType.StoredProcedure;
comm.Parameters.Add("@Id", SqlDbType.VarChar).Value = txtId.Text;
comm.Parameters.Add("@Name", SqlDbType.DateTime).Value = txtName.Text;
comm.Parameters.Add("@Address", SqlDbType.DateTime).Value = txtaddress.Text;
sqlConnection.Open();
return comm.ExecuteNonQuery();
sqlConnection.Close();
}
catch (SqlException ex)
{
Console.WriteLine("SQL Error" + ex.Message.ToString());
return 0;
}
I hope it will help you..