Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML and Datasets

Status
Not open for further replies.

rdgerken

Technical User
Jul 8, 2002
108
I have a compact framework application that is pulling data from a SQL server. When I'm in an online mode, I just use the dataset returned from the database to run my code... no problems there. But, I'm also using the Dataset.WriteXML(path) to write the data to the storage of the device so that if I need to work in an offline mode, I just do a Dataset.ReadXML(path) to get a dataset to work with. I get a very strange problem that I'm hoping someone can offer some assitance with. When I'm using the dataset that does NOT come from the ReadXML method, I have no issues at all. When I use the dataset that does come from the ReadXML method, I get an InvalidOperationException when I delete a row from the dataset in a foreach loop. The code that executes to delete these rows from the dataset are identical for both the SQL originating dataset and the XML originating dataset. I thought a dataset was a dataset. I can't understand why I get an issue with the one and not the other. Thanks for any help!
 
OK, after digging around a little, I found that my problem isn't necessarily related to what the dataset originates from. My problem is that if I try to delete more than one row of the dataset I get this problem. Can you use a foreach loop to go through each row of the dataset, deleting specific rows, and then accepting changes at the end, or what is the proper way to do that?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top