Adding a new row to a dataset

G

Guest

I have a tabbed form that contains data in a similar style to the Add/Edit Contact form from Outlook.

The data is read in using a dataAdapter and fed into a strongly typed dataset.

The dataset contains at present 7 tables, that are linked by various dataRelations.

I can quite happily view details of individual contacts, and see rows from child tables etc.

However, when I try and add a new row to the dataset and change the BindingContext to display it in my form, I get the following error:

System.ArgumentException: Cannot create a child list for field customersiteid

CustomerSiteID is the primary key for the table I am attemptimg to add a row to in the dataset.

The code I am using to add the row and update the binding position is as follows:

CustomerSiteFormDataSet.customersiteRow newRow = this.customerSiteFormDataSet.customersite.NewcustomersiteRow();

this.customerSiteFormDataSet.customersite.AddcustomersiteRow(newRow);

this.BindingContext[this.customerSiteFormDataSet, "customersiteid"].Position++;

I have set the primary key of the datatable to be autoincrementing. The actual insert to the table seems to work fine, it is only when I attempt to look at the new row that the exception occurs. I can see the table row count increasing as it should.

This sounds like such a simple thing, but I am new to dat binding and am stumped.

Thanks
 
G

Guest

Sorry guys - my own stupidity. Was trying to get the BindingContext back from customersiteid (a column) instead of customersite (the table).

Only took about 4 hours to work out this idiocy.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top