I have a C# program where the INSERT, SELECT works fine. I want to try and UPDATE my DataGridView
to the database.
If I delete a row in the GridView then it is sent to the db as a DataTable and all of this works fine except one thing, it writes new entries to that my three rows which should be 2 after delete becomes 5.
Here is my code:
public void Update(DataTable dataforupdate, string table)
{
if (table == "Musik")
{
SQLiteDataAdapter adapter = new SQLiteDataAdapter("SELECT * FROM Musik",m_dbConnection);
SQLiteCommandBuilder builder = new SQLiteCommandBuilder(adapter);
adapter.Update(dataforupdate);
}
}
It should delete the table and then insert the datatable with all data (as it is the easiest thing to do when having multiple deletes or inserts).
EDIT: It now copies the table and inserts it, so the table is in there 2x times. It seems a bit unnecessary to use a "DELETE FROM Musik" before adding the DataTable, but it does work, if you can help I would like to know a better solution.