Microsoft KB Archive/912604

= The DataSet schema that is generated by the SqlDataAdapter control does not change when you change the SELECT query in Visual Studio 2005 =

Article ID: 912604

Article Last Modified on 4/14/2006

-

APPLIES TO


 * Microsoft Visual Studio 2005 Professional Edition
 * Microsoft Visual Studio .NET 2003 Professional Edition
 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Academic Edition

-





SYMPTOMS
Consider the following scenario. You upgrade a project from Microsoft Visual Studio .NET 2003 to Microsoft Visual Studio 2005. This project contains the SqlDataAdapter control. In the SqlDataAdapter control, you change the SELECT query. In this scenario, the DataSet schema that is generated by the SqlDataAdapter control does not change.



CAUSE
This behavior occurs in Visual Studio 2005 because the DataSet schema that is returned by the changed SELECT query is merged with the DataSet schema that is returned by the initial query. The new columns are added to the existing DataSet schema.

This behavior differs from the behavior in Visual Studio .NET 2003. In Visual Studio .NET 2003, the DataSet schema that is returned by the changed SELECT query replaces the DataSet schema that is returned by the initial query.



WORKAROUND
To work around this behavior, use one of the following methods:
 * Delete the DataSet schema, and then add a new DataSet schema. To do this, follow these steps:
 * Create a new DataSet schema that has all the required tables.
 * Delete the old DataSet schema.
 * Rename the new DataSet schema to the name of the old DataSet schema.
 * Delete the unnecessary columns from the DataSet schema. After you rebuild the project, the DataSet schema is updated.



STATUS
This behavior is by design.



Steps to reproduce the behavior
 In Visual Studio .NET 2003, create a new Microsoft Windows application by using Microsoft Visual Basic .NET 2003 or Microsoft Visual C# .NET 2003. By default, a form that is named Form1 is created. Create a new data connection. To do this, follow these steps:  On the View menu, click Server Explorer. In Server Explorer, right-click Data Connections, and then click Add Connection. In the Data Link Properties dialog box, click the Connection tab.</li> In the Select or enter a server name box, type the name of the local computer that is running Microsoft SQL Server.</li> Under Enter information to log on to the server, click Use Windows NT Integrated security.</li> In the Select the database on the server list, click AdventureWorks.</li> Click OK.</li></ol> </li> Add a SqlConnection control to the Form1 form.</li> Right-click the SqlConnection1 control, and then click Properties.</li> In the Properties window, set the value of the ConnectionString property to the data connection that you created in step 2.</li> Add a SqlDataAdapter control to the Form1 form.</li> In the Data Adapter Configuration Wizard, click Next three times, and then type the following SQL statement:

select * from Contact

</li> Click Next, and then click Finish.</li> Right-click the SqlDataAdapter1 control, click Generate Dataset, and then click OK.</li> On the File menu, click Save, and then exit Visual Studio .NET 2003.</li> In Visual Studio 2005, open the Windows application that you saved in step 10.</li> After the Migration Wizard finishes, right-click the SqlDataAdapter1 control, and then click Configure Data Adapter.</li> In the Data Adapter Configuration Wizard, click Next two times, and then type the following SQL statement:

select ContactID, NameStyle from Contact

</li> Click Finish.</li> <li>Right-click the SqlDataAdapter1 control, click Generate Dataset, and then click OK.</li> <li>In the Visual Studio 2005 IDE, click the DataSet1.xsd tab. Notice that the DataSet schema does not change.</li></ol>

Keywords: kbtshoot kbprb KB912604

-

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

© Microsoft Corporation. All rights reserved.