This code doesn’t change the column (I try to increase the column orderTillNow value by one…), table: items.
SqlConnection connection = new SqlConnection("Data Source=***:*******.com;Initial Catalog=****;User ID=*****;Password=******;Integrated Security=False;");
using (SqlCommand command = new SqlCommand("UPDATE items SET ordersTillNow = ordersTillNow + 1 "))
{
connection.Open();
command.Connection = connection;
command.ExecuteNonQuery();
connection.Close();
}
I’ve tried to put that statement into SQL Server Management Studio – and that works. Why does my C# not change the value?
Your forgot:
In the end your code should look like this:
And note:
using-block againstSqlConnectionis much more important then againstSqlCommand.