开发者

DataGridView.DataMember throws error when assigned a two-part name. i.e. Sales.StoreContact

开发者 https://www.devze.com 2023-01-16 10:20 出处:网络
My problem is outlined here: https://support.microsoft.com/kb/314043 Microsoft says: "This behavior is by design." and no workaround is provided.

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>


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


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"?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号