An unhandled exception of the 'System.ArgumentException' type occurs after you rename the columns of a DataSet object (815545)
The information in this article applies to:
- Microsoft ADO.NET (included with the Windows .NET Framework 1.1)
- Microsoft ADO.NET (included with the .NET Framework) 1.0
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual C# .NET (2003)
- Microsoft Visual C# .NET (2002)
SYMPTOMSAfter you rename the columns of a DataTable object in the DataSet, if you try to refer to the columns in case-insensitive manner,
you receive the following exception: An unhandled
exception of type 'System.ArgumentException' occurred in
system.data.dll Additional information: Column 'ColumnName' does not belong
to table 'Tablename'. CAUSEWhen you first create a column in a DataTable object of a DataSet, the name is added to two indexes: a case-sensitive index and a
case-insensitive index. When you rename the column in a DataTable object, the new name is not added to the case-insensitive index.
Therefore, when you rename a DataTable column, the ColumnName becomes case-sensitive.
RESOLUTIONTo work around this problem after you rename the columns,
copy the Dataset to itself. To do this, rename the columns, and then add the
following statement to the code. Microsoft Visual Basic .NET code
ds=ds.Copy() Microsoft Visual C# .NET code
ds=ds.Copy(); STATUS This
behavior is by design.REFERENCES For additional information, click
the following article number to view the article in the Microsoft Knowledge
Base: 308656
How to open a SQL Server database by using the SQL Server .NET data provider with Visual Basic .NET
For more information about using .NET Framework data
providers to access data, see the documentation in the Microsoft .NET Framework
Software Development Kit, or visit the following MSDN Web site:
Modification Type: | Minor | Last Reviewed: | 3/9/2006 |
---|
Keywords: | kbtable kbSqlClient kbProvider kbDataBinding kbDatabase kbDataAdapter kbprb KB815545 kbAudDeveloper |
---|
|