I am trying to ensure the interaction of my DataGrid with SQLite database with standard, such as mechanics:
private void mainTabControl_Loaded(object sender, RoutedEventArgs e) { MainAdapter = new SQLiteDataAdapter("SELECT * FROM Main", _connection); MainCommandBuilder = new SQLiteCommandBuilder(MainAdapter); MainAdapter.Fill(MainTable); mainGrid.DataContext = MainTable.DefaultView; FillMainDeptComboBox(); MainTable.TableNewRow += (o, args) => { MainAdapter.Update(MainTable); }; MainTable.RowChanged += (o, args) => { MainAdapter.Update(MainTable); }; } Edited lines are regularly translated into DB. Problems arise when a new row is created and added to the DataGrid, and then when I try to edit it, I get: System.Data.DBConcurrencyException. Obviously, this is due to the presence in the table of the bd column "id" with auto-increment. I have a rough idea of how to manually drop this value into the DataTable, but first I would like to know if there are any prepared tools for this?
MainAdapter.Fill(MainTable);what value returnsMainTable.Columns["id"].AutoIncrement? - Stack