C# ASP.NET Update database with datatable

Posted by Sir Graystar on Stack Overflow See other posts from Stack Overflow or by Sir Graystar
Published on 2010-06-03T10:23:32Z Indexed on 2010/06/03 10:54 UTC
Read the original article Hit count: 246

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET