how to update sql in c#. code example
Example: sql server update c# example code
string name = "test1";
int id = 1;
using (SqlConnection cnn = new SqlConnection("Server=localhost;Database=DEV;User Id=test;Password=test!@#$;Connect Timeout=5400"))
{
cnn.Open();
string querystr = "UPDATE [dbo].[TABLE] SET [name]=@p_name WHERE [id]=@p_id";
using (var cmd = new SqlCommand(querystr, cnn))
{
cmd.Parameters.AddWithValue("@p_name", name);
cmd.Parameters.AddWithValue("@p_id", id);
int ret = cmd.ExecuteNonQuery();
}
}