DataGridView.DataMember throws error when assigned a two-part name. i.e. Sales.StoreContact
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</Name>
<ReasonType>Damaged</ReasonType>
<ModifiedDate>2010-01-05T00:00:00+00:00</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"?
精彩评论