My sqlite code for linking db table to datagrid is:
sqlitecon.Open();
string Query2 = "Select * from Security_details ";
SQLiteCommand createCommand2 = new SQLiteCommand(Query2, sqlitecon); createCommand2.ExecuteNonQuery();
SQLiteDataAdapter dataAdp2 = new SQLiteDataAdapter(createCommand2);
DataTable dt2 = new DataTable("Security_details");
dataAdp.Fill(dt2);
datagrid_security.ItemsSource = dt2.DefaultView;
dataAdp2.Update(dt2);
sqlitecon.Close();
This code links db table to datagrid during form load event.
I want user to be able to:
- add new rows on datagrid get inserted into db
- edit existing rows on datagrid get updated into db.
Here in following query are my database fields
SQLiteCommand comm = new SQLiteCommand("update Security_details " +
"set id=@id,Code=@Code,Description=@Description,Rate=@Rate," +
"Qty=@Qty,Amount=@Amount,Remarks=@Remarks where id=@id", sqlitecon);
Please tell me the set of commands for inserting and editing db table through datagrid ?Thanks