I have a reasonably complicated database with 18 tables that I load into a dataset and then call AcceptChanges to make sure I am at a neutral position. I then give the DataSet to the UltraGrid via a BindingSource, go into update mode and delete one row for a table that should only affect two other linked tables. I have established many relationships between the tables but this table only has 2 relationships.
To post the data back to the database, I call DataSet.GetChanges hoping to be efficient but I get all 18 tables back albeit many have 0 or 1 row in them. I am not able to update the database unless I update every table as skipping the ones that have 0 rows causes a concurrency violation. Can anyone shed any light on why I get all my tables when calling GetChanges when only 3 should be affected? Or the proper technique after the grid touches the dataset in order to get only the ones that I really have to update? This has me stumped. Thanks, Dave
OK I solved the problem. DON'T EVER CALL DATASET.GETCHANGES()!!!!!!!!!
I switched to calling GetChanges() on every table in the Dataset instead and everything works great adn exactly as I would think it should! What an incredible waste of time this was. This is a problem with the MSFT DataSet version of GetChanges and not Infragistics at all as far as I can tell!!!
Sorry for the bother. Thanks, Dave
For testing, I got rid of the BindingSource and am having the same issue with a DataSet/tablename and incredibly with just a DataTable by itself!
I have 18 SQL Server 2008 tables loaded into a 3.5 DataSet via Fill calls by the SqlDataAdapter. I have removed all the relations, got rid of the FillSchema calls, called AcceptChanges, verified that GetChanges returns null and still when the Infragistics data grid deletes one row from one table, when I call GetChanges again, so I know what to push back and what to communicate to another component that changed, I get all 18 of my tables returned in the GetChanges() copy albeit most of the tables return a 0 count for the Tables.Rows.Count property. Still I need to know exactly what tables have changed. Many of these tables are related in the actual database but this table has only a couple relations with other tables, and none of those relations are defined in this case. I have debugged from "before row deleted" to "after row deleted" in Infragistics grid and there are no more calls into my data layer unless somehow the DataSet object is grabbed from the DataTable I gave the grid and the DataSet accessed directly. I sure don't read this as normal behaviour of GetChanges.
Any insight from anyone greatly appreciated. I am pulling hair out on this one...
- Dave
Thanks Mike. One reason I was thinking is maybe because of using a BindingSource, going into update mode potentially creates a new row for each table even though none are actually added to the tables. GetChanges mentioned something like that. Do you have any BindingSource with relations example to a real database that you can test this with? It will take me a while to pare my code down as it is rather complex. I cannot find anything on the net that claims similar issues. - Dave
Hi Dave,
I can't see any reason why this would happen. As far as the grid is concerned, it will only updated the row you change or delete. The grid doesn't do anything to update relationships beyond that. That's up the data source itself to handle.
I also can't imagine why GetChanges would return you a table with 0 rows. That doesn't seem to make sense.
Just as a test, have you tried taking the grid out of the equation and simply deleting a row directly on the DataTable to see if you get the same results? If you do, then this is clearly a DataSet issue nothing to do with the grid. If not, it might be because the grid is accessing the data in a slightly different way than you are - through the BindingManager, but it's also possible (thought it seems very unlikely) that there is some obscure grid bug here.