0

My problem is outlined here: https://support.microsoft.com/kb/314043 Microsoft says: "This behavior is by design." and no workaround is provided.

I need a workaround.

I have a dataset which is populated correctly with the contents of the table name Sales.StoreContact.

When I try DataGridView1.DataMember="Sales.SalesContact" the IDE throws:

Argument Exception was unhandled.
Child list for field Sales cannot be created.

I don't want to rename my tables either.

the dataset contains

<NewDataSet>
  <Sales.SalesContact>
    <SalesContactID>1</SalesContactID>  
    <Name>Jimmy&lt;/Name>  
    <ReasonType>Damaged&lt;/ReasonType>  
   <ModifiedDate>2010-01-05T00:00:00+00:00&lt;/ModifiedDate>  
  </Sales.SalesContact>  
</NewDataSet>
TylerH
  • 20,799
  • 66
  • 75
  • 101
user323186
  • 95
  • 1
  • 3
  • 9

2 Answers2

1

Check your spaces. I just ran into the same error and I had a space at the end of the table name. For example, tablename and not tablename

TylerH
  • 20,799
  • 66
  • 75
  • 101
Reg
  • 1
  • 1
0

Update: If your DataTable itself is called "Sales.SalesContact", you could try setting the DataGridView.DataSource property directly to the DataTable (instead of the DataSet):

Dim salesContactTable As DataTable = dataSet.Tables("Sales.SalesContact")
dataGridView.DataSource = salesContactTable

So you're saying you have a DataSet called "Sales", which contains a table called "SalesContact"?

Did you try setting your DataGridView.DataSource property to your "Sales" DataSet and DataGridView.DataMember to simply "SalesContact"?

Dan Tao
  • 125,917
  • 54
  • 300
  • 447
  • 1 Jimmy Damaged 2010-01-05T00:00:00+00:00 – user323186 Sep 15 '10 at 12:53
  • @user323186: I see. So your table itself is called "Sales.SalesContact"? – Dan Tao Sep 15 '10 at 13:00
  • just tried that. unfortunately the same result. Child list for field SalesContact cannot be created. So to confirm I did it correctly I did: Dim salesContactTable As DataTable = dsTableContents.Tables("Sales.SalesContact"), then associated datasource to salesContactTable and datamember to SalesContact. Any other suggestions? – user323186 Sep 15 '10 at 14:18
  • @user323186: Sorry for all the failed attempts. But my suggestion was a *bit* different from what you just said; I was suggesting to set the `DataSource` to the table (as you did) **but leave `DataMember` blank**; don't assign it to anything. What happens when you try that? – Dan Tao Sep 15 '10 at 14:26
  • Its looking good. Thank you very much. Strange tho, as i tried that before with the datasource and it didnt work, but fine when I used the dataTable. Would love to know why. But anywho, thank you. – user323186 Sep 15 '10 at 14:39