Originally posted by RedSon
Help with SQL Mobile and data sets
Collapse
X
-
I think I got it figured out. The problem was with the merge call. The data set that the user updates already has the changes so mergeing them just merges double the data, and when you have values that must be unique it throws errors. -
I guess I need to know what event is triggered when the user finishes editing a row. Then I can call getChanges then and I will have all values in each column and not need to worry about null values.Originally posted by kenobewanYou have described the problem exactly. Either nulls are allowed or all columns changes are inserted at the same time. Consequently, all changes would need to be identified on one event (maybe tricky) or each change event updates all columns with new or current values (pretty inefficient).
Would it be helpful to identfy only the changes to update and use these as parameters, rather than using one update statement in the dataadapter (updating everything?). I use stored procedures for these, but only sqlcommands available to you. HTH.Leave a comment:
-
You have described the problem exactly. Either nulls are allowed or all columns changes are inserted at the same time. Consequently, all changes would need to be identified on one event (maybe tricky) or each change event updates all columns with new or current values (pretty inefficient).Originally posted by RedSonThe issue is when the user adds a row it throws an unhandled exception of type 'System.Data.Co nstraintExcepti on' occurred in System.Data.dll , but the only constraints that the DB has is that none of the columns can be null. But the user has not finished entering in the information into the datagridview yet so some of the colums will be null. I don't know what the heck is going on with this. I'm at my wits end....MSDN sucks.
Would it be helpful to identfy only the changes to update and use these as parameters, rather than using one update statement in the dataadapter (updating everything?). I use stored procedures for these, but only sqlcommands available to you. HTH.Leave a comment:
-
Help with SQL Mobile and data sets
HELP!
The issue is when the user adds a row it throws an unhandled exception of type 'System.Data.Co nstraintExcepti on' occurred in System.Data.dll , but the only constraints that the DB has is that none of the columns can be null. But the user has not finished entering in the information into the datagridview yet so some of the colums will be null. I don't know what the heck is going on with this. I'm at my wits end....MSDN sucks.Code:private void dataGridView1_UserAddedRow(object sender, DataGridViewRowEventArgs e) { MessageBox.Show("dataGridView1_UserAddedRow"); if (this.bookDataSet.HasChanges()) { DataSet changes = this.bookDataSet.GetChanges(); this.booksTableAdapter.Connection.Open(); this.booksTableAdapter.Update((BookApplication.bookDataSet)changes); this.booksTableAdapter.Connection.Close(); this.bookDataSet.Merge(changes, true, MissingSchemaAction.Add); DataRow[] errRows = this.bookDataSet.Tables["books"].GetErrors(); foreach (DataRow errRow in errRows) { errRow.RejectChanges(); errRow.RowError = null; } this.bookDataSet.AcceptChanges(); } }Tags: None
Leave a comment: