How To Update Database From Datagridview In C#.net

  
How To Update Database From Datagridview In C#.net

Hi, if you use the CommandBuilder to update a table it must include a primary key. File Explorer Nokia N73 Sis File more. The DataAdapter create this only if MissingSchemaAction.AddWithKey is. I can add, edit, delete database using listbox. But I want to do it using DatagridView I already bind it to my database. How do I add,edit,delete update my database.

I believe that in order for the DataAdapter.Update() to work correctly, your database table needs to have a PrimaryKey and your DataTable also needs to have a Primary Key. Using Gi Bill On Active Duty. See this link: There are other ways to update database tables without requiring a PrimaryKey on your DataTable, but not if you want to use the.Update() method. In case you're interested, I have a 3-part series on my blog.

I'm using a SQL database, but the same would apply to other databases (except you'd use OleDb classes instead of Sql classes): Each post adds extra complexity to the Data Access classes, but more flexiblity. The first post is enough to get you going in the right direction and give you a general idea of the concept, but the second post is more useful. The third post gets into using anonymous delegates. ~~Bonnie Berent DeWitt [C# MVP]. I believe that in order for the DataAdapter.Update() to work correctly, your database table needs to have a PrimaryKey and your DataTable also needs to have a Primary Key. See this link: There are other ways to update database tables without requiring a PrimaryKey on your DataTable, but not if you want to use the.Update() method. In case you're interested, I have a 3-part series on my blog.

I'm using a SQL database, but the same would apply to other databases (except you'd use OleDb classes instead of Sql classes): Each post adds extra complexity to the Data Access classes, but more flexiblity. The first post is enough to get you going in the right direction and give you a general idea of the concept, but the second post is more useful. The third post gets into using anonymous delegates. ~~Bonnie Berent DeWitt [C# MVP].