Microsoft KB Archive/314043

= An &quot;An unhandled exception of type 'System.ArgumentException' occurred&quot; error message occurs if the DataTable name or DataRelation name includes a period =

Article ID: 314043

Article Last Modified on 5/13/2007

-

APPLIES TO


 * Microsoft ADO.NET 2.0
 * Microsoft .NET Framework 1.1 Service Pack 1

-



This article was previously published under Q314043



This article refers to the following Microsoft .NET Framework Class Library namespaces:
 * System.Data
 * System.Data.OleDb
 * System.Data.SqlClient



SYMPTOMS
The DataMember property of a DataGrid control uses a period (.) to separate DataTable and DataRelation names. The period is used to separate parent and child elements.

If the DataMember property is set to a DataTable or DataRelation name that includes a period, the property takes only the characters to the left of the period and returns the following error message:

An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll

Additional information: Can't create a child list for field Cust.



STATUS
This behavior is by design.



Steps to reproduce the behavior
 Start Microsoft Visual Studio .NET. Create a new Windows Application project in Visual Basic .NET. By default, Form1 is added to the project. Make sure that your project contains a reference to the System.Data namespace. Place one Button control and one DataGrid control on Form1. Change the Name property of the button to btnTest, and then change the Text property to Test .  Use the Imports statement on the System, the System.Data, and the System.Data.SqlClient namespaces so that you are not required to qualify declarations in those namespaces later in your code. Add the following code to the &quot;General Declarations&quot; section of Form1: Imports System Imports System.Data.OleDb Imports System.Data.SqlClient </li>  Add the following code to the Code window after the &quot;Windows Form Designer generated code&quot; region: Private Sub btnTest_Click(ByVal sender As System.Object, _   ByVal e As System.EventArgs) Handles btnTest.Click Dim myConnString As String = _ &quot;User ID=sa;password=sa;Initial Catalog=Northwind;Data Source=myServer&quot; Dim ds As New DataSet Dim con As New SqlConnection(myConnString) Dim daCust As New SqlDataAdapter(&quot;Select * From Customers&quot;, con) daCust.Fill(ds, &quot;Cust.Details&quot;) DataGrid1.DataSource = ds       DataGrid1.DataMember = &quot;Cust.Details&quot; End Sub </li> Modify the connection string (myConnString) as appropriate for your environment.</li> Save your project. On the Debug menu, click Start to run your project.</li> Click Test. Notice that DataGrid1.DataMember fails with the above-mentioned exception.</li></ol>

<div class="references_section">