I have a datagridview filled with a table of my database in my winforms Application.
Then I want to save datagridview to my database when I make changes to datagridview. I'm using sql Database.
Here is my code:
DataTable allData = new DataTable();
SqlCommand cmd = new SqlCommand("Select * from contactTable", Connection);
cmd.CommandType = CommandType.StoredProcedure;
Connection.Open();
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
adapter.Fill(allData);
Connection.Close();
contactTableTableAdapter.Update(allData);
But nothing happens with this code.
At last I used insert statrements to enter the dataGridView to my database.