An "An unhandled exception of type 'System.ArgumentException' occurred" error message occurs if the DataTable name or DataRelation name includes a period (314043)



The information in this article applies to:

  • Microsoft ADO.Net 2.0
  • Microsoft ADO.NET (included with the .NET Framework)

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.

MORE INFORMATION

Steps to reproduce the behavior

  1. Start Microsoft Visual Studio .NET.
  2. Create a new Windows Application project in Visual Basic .NET. By default, Form1 is added to the project.
  3. Make sure that your project contains a reference to the System.Data namespace.
  4. Place one Button control and one DataGrid control on Form1.
  5. Change the Name property of the button to btnTest, and then change the Text property to Test.
  6. 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 "General Declarations" section of Form1:
    Imports System
    Imports System.Data.OleDb
    Imports System.Data.SqlClient
    					
  7. Add the following code to the Code window after the "Windows Form Designer generated code" region:
        Private Sub btnTest_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles btnTest.Click
            Dim myConnString As String = _
                    "User ID=sa;password=sa;Initial Catalog=Northwind;Data Source=myServer"
            Dim ds As New DataSet()
            Dim con As New SqlConnection(myConnString)
            Dim daCust As New SqlDataAdapter("Select * From Customers", con)
            daCust.Fill(ds, "Cust.Details")
            DataGrid1.DataSource = ds
            DataGrid1.DataMember = "Cust.Details"
        End Sub
    					
  8. Modify the connection string (myConnString) as appropriate for your environment.
  9. Save your project. On the Debug menu, click Start to run your project.
  10. Click Test. Notice that DataGrid1.DataMember fails with the above-mentioned exception.

REFERENCES

For more information on ADO.NET objects and syntax, refer to the following Microsoft .NET Framework Software Development Kit (SDK) documentation or MSDN Online:

Modification Type:MajorLast Reviewed:3/13/2006
Keywords:kbtshoot kberrmsg kbDataBinding kbfix kbprb kbSqlClient kbSystemData KB314043 kbAudDeveloper