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



The information in this article applies to:

  • Microsoft Visual Studio 2005 Professional Edition
  • Microsoft Visual Studio .NET (2003), Professional Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • 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:
    1. Create a new DataSet schema that has all the required tables.
    2. Delete the old DataSet schema.
    3. 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.

MORE INFORMATION

Steps to reproduce the behavior

  1. 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.
  2. Create a new data connection. To do this, follow these steps:
    1. On the View menu, click Server Explorer.
    2. In Server Explorer, right-click Data Connections, and then click Add Connection.
    3. In the Data Link Properties dialog box, click the Connection tab.
    4. In the Select or enter a server name box, type the name of the local computer that is running Microsoft SQL Server.
    5. Under Enter information to log on to the server, click Use Windows NT Integrated security.
    6. In the Select the database on the server list, click AdventureWorks.
    7. Click OK.
  3. Add a SqlConnection control to the Form1 form.
  4. Right-click the SqlConnection1 control, and then click Properties.
  5. In the Properties window, set the value of the ConnectionString property to the data connection that you created in step 2.
  6. Add a SqlDataAdapter control to the Form1 form.
  7. In the Data Adapter Configuration Wizard, click Next three times, and then type the following SQL statement:

    select * from Contact

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

    select ContactID, NameStyle from Contact

  14. Click Finish.
  15. Right-click the SqlDataAdapter1 control, click Generate Dataset, and then click OK.
  16. In the Visual Studio 2005 IDE, click the DataSet1.xsd tab. Notice that the DataSet schema does not change.

Modification Type:MajorLast Reviewed:4/14/2006
Keywords:kbtshoot kbprb KB912604 kbAudITPRO kbAudDeveloper