Microsoft KB Archive/317175

= BUG: DataColumn.MaxLength property is not set for strongly typed DataSets =

Article ID: 317175

Article Last Modified on 3/10/2006

-

APPLIES TO


 * Microsoft .NET Framework 1.1 Service Pack 1
 * Microsoft ADO.NET 1.1
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Enterprise Developer

-



This article was previously published under Q317175



SYMPTOMS
If you create a strongly typed DataSet, the DataColumn.MaxLength property is not set.



RESOLUTION
To resolve this issue, use the FillSchema method to get the DataColumn.MaxLength property, or set the MissingSchemaAction property to AddWithKey.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior
 Open Visual Studio .NET, and then create a new Microsoft Visual Basic .NET Windows Application. Add a command button to Form1. Create a typed DataSet to the Northwind database. Use &quot;SELECT * FROM customers&quot; as the SQL statement.

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

315678 HOW TO: Create and Use a Typed DataSet in .NET

  Copy and paste the following code into the button1_click event: SqlDataAdapter1.Fill(DataSet11, &quot;customers&quot;) 'SqlDataAdapter1.FillSchema(DataSet11, SchemaType.Mapped) MessageBox.Show(DataSet11.Customers.CustomerIDColumn.MaxLength)  Save the project, and then run the project. Notice that the MessageBox displays -1.</li> Uncomment the FillSchema line of code, and then run the project.</li> Notice that the correct value appears.</li></ol>

NOTE: Instead of FillSchema, you can use the following before the Fill method is called: SqlDataAdapter1.MissingSchemaAction = MissingSchemaAction.AddWithKey NOTE: Because FillSchema requires an additional trip to the database to get the Schema information, using FillSchema can affect performance.

Keywords: kbtshoot kbbug kbsqlclient kbsystemdata kbvs2002sp1sweep KB317175

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.