Hi. I have followed this tutorial and i am now showing data in my DataGridView:
Now I want to be able to modify the data and write it back to the database. How would i do this ? Create a function called SaveData and:Code:void FillData() { // 1 // Open connection using (SqlCeConnection c = new SqlCeConnection( Properties.Settings.Default.DataConnectionString)) { c.Open(); // 2 // Create new DataAdapter using (SqlCeDataAdapter a = new SqlCeDataAdapter( "SELECT * FROM Animals", c)) { // 3 // Use DataAdapter to fill DataTable DataTable t = new DataTable(); a.Fill(t); // 4 // Render data onto the screen dataGridView1.DataSource = t; } } }
- create a connection
- create a new adapter ( that writes )
- create the datatable
- write datatable to new adapter using the connection
I was wondering if that thought process is correct. I barely have any C# coding experiences alltho this does not seem so hard. Help is appreicated


Reply With Quote
Bookmarks