I know this is probably simple, but I have a SQL DB that gets filled into a dataset with 3 tables. The three tables represent a many to many relationship, two data tables with primary keys and a bridge table. Basically, it is to track events and resources that are associated with those events. The schema is as follows (I have eliminated non-relevant fields for clarity):
basically, the user selects an event, and I loop through the tbl_event_resources and getChildRows on it to retrieve the resources that are associated with the event. Here is the code to loop through and add the used resources to a listview:
foreach (DataRow eventResourceRow in EventDetailsDataSet.Tables["tbl_event_resources"].Rows)
resourceRows = eventResourceRow.GetChildRows("tbl_resourcestbl_event_resources", DataRowVersion.Current);
foreach (DataRow resourceRow in resourceRows)
This code works great (and correctly gives me the resources for the specific event) as long as the dataset is simply filled via an adapter. However, when I add a row in code, things start going haywire.
long resourceId = ((DataMenuItem)sender).ID; //This number IS the correct number
Now, when the foreach above is run, it will still show me the original child rows, but I either get no additional resources from GetChildRows, or I get one that is not the one I actually added. I thought at first I had my relationship defined wrong, but in that case the originals wouldn't show up correctly.
The relationship in the dataset is defined as follows:
Parent Element: tbl_event_resources
Key Fields,Foreign Key Fields:
Anyone have any idea what I am doing wrong?