You are currently offline, waiting for your internet to reconnect

"Type 'DataSetName' is not defined" error message when you build the project

SYMPTOMS
When you create a DataSet during design time by using the Generate DataSet option of a DataAdapter, an instance of the DataSet is automatically created on the form. When you modify the name of the DataSet in the Properties window, save the project, and then try to open the form, you may receive the following error message on the form:
An error occurred while loading the document. Fix the error, and then try loading the document again. The error message follows:
Unspecified error
When you build your project, you may receive the following error message:
Type 'ApplicationName.OldDataSetName' is not defined.
CAUSE
The problem occurs because when the DataSet name is changed in the DataSet schema file (.xsd), Microsoft Visual Studio 2005 or Microsoft Visual Studio .NET does not modify the DataSet name in the InitializeComponent of the form where the DataSet is initialized.
RESOLUTION
To resolve this problem, replace the DataSet name with the new name in the code. To do this, follow these steps:
  1. On the View menu, click Code.
  2. In the code, replace each instance of the Dataset name from DataSet1 to MyDataSet.
  3. Save the project, and then in Solution Explorer, double-click Form1.cs.
STATUS
This behavior is by design.
MORE INFORMATION

Steps to Reproduce the Behavior

  1. In Microsoft Visual Studio .NET, create a new Visual C# Windows Application project. By default, Form1 is created.
  2. On the View menu, click Server Explorer.
  3. In Server Explorer, right-click Data Connections, and then click Add Connection.
  4. In the Data Link Properties dialog box, on the Connection tab, type your local SQL Server name, and then select the Northwind database.
  5. On the Data tab of the Toolbox, drag a SqlConnection to Form1.
  6. Right-click SqlConnection1, and then click Properties. In the Properties dialog box, set ConnectionString to the data connection that you created in step 4.
  7. Drag a SqlDataAdapter from the Toolbox to Form1. In the Data Adapter Configuration Wizard, click Next three times, and then type the following SQL statement:
    Select * From Customers
  8. Click Next, and then click Finish to close the wizard.
  9. Right-click SqlDataAdapter1, and then click Generate Dataset. Click OK.
  10. On the View menu, click Solution Explorer.
  11. In Solution Explorer, double-click DataSet1.xsd.
  12. On the View menu, click Properties Window.
  13. In the Properties pane, select DataSetName, and then change the name to MyDataSet.
  14. Save the project, and then in Solution Explorer, double-click Form1.cs.
  15. On the Build menu, click Build Solution.
REFERENCES
For more information, visit the following Microsoft Developer Network (MSDN) Web sites:
Properties

Article ID: 816801 - Last Review: 05/12/2007 08:28:03 - Revision: 2.10

Microsoft ADO.NET 2.0, Microsoft ADO.NET 1.1, Microsoft ADO.NET 1.0, Microsoft Visual C# 2005 Express Edition, Microsoft Visual C# .NET 2003 Standard Edition, Microsoft Visual C# .NET 2002 Standard Edition, Microsoft Visual Basic 2005, Microsoft Visual Basic .NET 2003 Standard Edition, Microsoft Visual Basic .NET 2002 Standard Edition

  • kbprb kbcode kberrmsg kbsystemdata kbwindowsforms kbtable kbsqlclient kbschema kbdesigner kbdatabase kbdataadapter KB816801
Feedback
dy>play:none;" onerror="var m=document.createElement('meta');m.name='ms.dqp0';m.content='true';document.getElementsByTagName('head')[0].appendChild(m);" onload="var m=document.createElement('meta');m.name='ms.dqp0';m.content='false';document.getElementsByTagName('head')[0].appendChild(m);" src="http://c1.microsoft.com/c.gif?">