Note that there are some explanatory texts on larger screens.

plurals
  1. POMy datagrid's selection is lost when updating my database from the grid's bound dataset. Any workarounds?
    primarykey
    data
    text
    <p>I am using Xceed's Datagrid, bound to a dataset. I want to update the database when the datagrid's RowEditEnd is called. The problem is that in order to avoid concurrency violations when updating, I have to clear the dataset after update and refill it, like this:</p> <pre><code>public void UpdateDatabaseFromDataSet() { adapter.Update(exampleDataSet); exampleDataSet.Clear(); adapter.Fill(exampleDataSet); } </code></pre> <p>I think I have to do this because my dataset's primary autoincrement column "ID" does not match the values generated by the database. When I clear the dataset, it clears the datagrid and its selected cell. This is very annoying since, if you edit a cell and hit enter or a directional key, the cell and database will update fine, but your selection gets reset instead of navigating to the next row/cell. This makes entering data by hand very cumbersome.</p> <p>Here is the method that creates the dataset:</p> <pre><code>public void InitDataSet(int tableid) { cmd = new SQLiteCommand("SELECT * FROM table_" + tableid, con); adapter = new SQLiteDataAdapter(cmd); cb = new SQLiteCommandBuilder(adapter); try { exampleDataSet = new DataSet(); adapter.Fill(exampleDataSet); prodDataSet.Tables[0].Columns[0].AutoIncrementSeed = -1; prodDataSet.Tables[0].Columns[0].AutoIncrementStep = -1; currenttableID = tableid; } catch (ApplicationException ex) { MessageBox.Show("Encountered an error.", "Error: " + ex.ToString()); } } </code></pre> <p>Note that I have tried setting the tables autoincrementseed and autoincrementsteps to -1 but I still get concurrency violations if I don't refill the dataset.</p> <p>I would really like my datagrid to work the way it does if I do not clear and refill the dataset. Is there anyway to avoid the concurrency violations I'm running into? Am I going about this the wrong way?</p> <p>Thanks for your help. -Steven</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload