C# ASP.NET Update database with datatable
- by Sir Graystar
Scenario: I'm just trying to update my database with the changes made by the user to their information. Here is my code:
SqlCommandBuilder cb = new SqlCommandBuilder(da);
dt.Rows[0][2] = txtname.Text;
dt.Rows[0][3] = txtinterests.Text;
dt.Rows[0][4] = txtlocation.Text;
da.SelectCommand = new SqlCommand(sqlcommand, conn);
da.Update(dt);
I know its going to be something obvious, but what have I missed? There are no errors, everything compiles correctly, but nothing happens. The record remains unchanged.