Microsoft KB Archive/821536

= FIX: A System.ArgumentException exception occurs when you try to create a Windows form that inherits from a Windows form that contains a dataset =

Article ID: 821536

Article Last Modified on 10/25/2005

-

APPLIES TO


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

-





SYMPTOMS
When you try to create a Windows form that inherits from a Windows form that contains a dataset in Microsoft Visual Studio .NET 2003, you may receive the following exception error message:

An unhandled exception of type 'System.ArgumentException' occurred in system.data.dll

Additional information: Cannot add primary key constraint since primary key is already set for the table.



CAUSE
If the dataset contains nested datatables, Visual Studio .NET incorrectly tries to add additional code to the inherited Windows form to enforce constraints on the inherited dataset. This code tries to add a constraint that already exists on the dataset. Therefore, the behavior that is mentioned in the &quot;Symptoms&quot; section occurs.



RESOLUTION
A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that this article describes. Apply it only to systems that are experiencing this specific problem.

To resolve this problem, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question. The English version of this hotfix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.  Microsoft .NET Framework 1.1 (on Windows Server 2003)

Date        Time   Version            Size    File name --  01-May-2003  11:25  1.1.4322.904    1,699,840  System.design.dll

Microsoft .NET Framework 1.1

Date        Time   Version            Size    File name --  14-Apr-2003  14:27  1.0.1199.34124     81,920  Microsoft.windowsinstaller.dll



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.



Create a Windows Application project

 * 1) Start Visual Studio .NET 2003.
 * 2) On the File menu, point to New, and then click Project.
 * 3) Under Project Types, click Visual Basic Projects, and then click Windows Application under Templates.
 * 4) In the Name box, type WindowsApplication, and then click OK. By default, the Form1.vb Windows form is created.

Add a dataset to the project, and add code to use the dataset
 In Solution Explorer, click the WindowsApplication project. On the Project menu, click Add New Item. In the Add New Item - Windows Application dialog box, click DataSet under Templates. Click Open. The Dataset1.xsd XML Schema is added to the project, and the DataSet view of the Dataset1.xsd XML Schema appears. Switch to XML view of the Dataset1.xsd XML Schema.</li>  Replace the existing XML code with the following XML code to add the XML schema of the authors table to the Dataset1.xsd XML Schema: <?xml version=&quot;1.0&quot; standalone=&quot;yes&quot;?> <xs:schema id=&quot;DataSet1&quot; targetNamespace=&quot;http://www.tempuri.org/DataSet1.xsd&quot; xmlns:mstns=&quot;http://www.tempuri.org/DataSet1.xsd&quot; xmlns=&quot;http://www.tempuri.org/DataSet1.xsd&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:msdata=&quot;urn:schemas-microsoft-com:xml-msdata&quot; attributeFormDefault=&quot;qualified&quot; elementFormDefault=&quot;qualified&quot;> <xs:element name=&quot;DataSet1&quot; msdata:IsDataSet=&quot;true&quot;> <xs:complexType> <xs:choice maxOccurs=&quot;unbounded&quot;> <xs:element name=&quot;authors&quot;> <xs:complexType> <xs:sequence> <xs:element name=&quot;au_id&quot; type=&quot;xs:string&quot; /> <xs:element name=&quot;au_lname&quot; type=&quot;xs:string&quot; /> <xs:element name=&quot;au_fname&quot; type=&quot;xs:string&quot; /> <xs:element name=&quot;phone&quot; type=&quot;xs:string&quot; /> <xs:element name=&quot;address&quot; type=&quot;xs:string&quot; minOccurs=&quot;0&quot; /> <xs:element name=&quot;city&quot; type=&quot;xs:string&quot; minOccurs=&quot;0&quot; /> <xs:element name=&quot;state&quot; type=&quot;xs:string&quot; minOccurs=&quot;0&quot; /> <xs:element name=&quot;zip&quot; type=&quot;xs:string&quot; minOccurs=&quot;0&quot; /> <xs:element name=&quot;contract&quot; type=&quot;xs:boolean&quot; /> </xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> <xs:unique name=&quot;Constraint1&quot; msdata:PrimaryKey=&quot;true&quot;> <xs:selector xpath=&quot;.//mstns:authors&quot; /> <xs:field xpath=&quot;mstns:au_id&quot; /> </xs:unique> </xs:element> </xs:schema> </li>  In the Code view of the Form1.vb Windows form, replace the existing code with the following code.

Note In the following code, modify the connection string depending on your environment. Public Class Form1 Inherits System.Windows.Forms.Form


 * 1) Region &quot; Windows Form Designer generated code &quot;

Public Sub New MyBase.New

'This call is required by the Windows Form Designer. InitializeComponent

'Add any initialization after the InitializeComponent call

End Sub

'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose End If       End If        MyBase.Dispose(disposing) End Sub

'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection Friend WithEvents SqlDataAdapter1 As System.Data.SqlClient.SqlDataAdapter Friend WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand Friend WithEvents SqlInsertCommand1 As System.Data.SqlClient.SqlCommand Friend WithEvents SqlUpdateCommand1 As System.Data.SqlClient.SqlCommand Friend WithEvents SqlDeleteCommand1 As System.Data.SqlClient.SqlCommand Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Dataset11 As WindowsApplication.DataSet1 <System.Diagnostics.DebuggerStepThrough> Private Sub InitializeComponent Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection Me.SqlDataAdapter1 = New System.Data.SqlClient.SqlDataAdapter Me.SqlDeleteCommand1 = New System.Data.SqlClient.SqlCommand Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand Me.SqlUpdateCommand1 = New System.Data.SqlClient.SqlCommand Me.Button1 = New System.Windows.Forms.Button Me.Dataset11 = New WindowsApplication.DataSet1 CType(Me.Dataset11, System.ComponentModel.ISupportInitialize).BeginInit Me.SuspendLayout '       'SqlConnection1 '       Me.SqlConnection1.ConnectionString = &quot;workstation id=WorkstationID;packet size=4096;&quot; & _ &quot;integrated security=SSPI;data source=DataSource;persist security info=False;initial catalog=pubs&quot; '       'SqlDataAdapter1 '       Me.SqlDataAdapter1.DeleteCommand = Me.SqlDeleteCommand1 Me.SqlDataAdapter1.InsertCommand = Me.SqlInsertCommand1 Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1 Me.SqlDataAdapter1.TableMappings.AddRange(New System.Data.Common.DataTableMapping {New System.Data.Common.DataTableMapping _           (&quot;Table&quot;, &quot;authors&quot;, New System.Data.Common.DataColumnMapping {New System.Data.Common.DataColumnMapping(&quot;au_id&quot;, &quot;au_id&quot;), _ New System.Data.Common.DataColumnMapping(&quot;au_lname&quot;, &quot;au_lname&quot;), New System.Data.Common.DataColumnMapping(&quot;au_fname&quot;, _                   &quot;au_fname&quot;), New System.Data.Common.DataColumnMapping(&quot;phone&quot;, &quot;phone&quot;), New System.Data.Common.DataColumnMapping _ (&quot;address&quot;, &quot;address&quot;), New System.Data.Common.DataColumnMapping(&quot;city&quot;, &quot;city&quot;), _ New System.Data.Common.DataColumnMapping(&quot;state&quot;, &quot;state&quot;), New System.Data.Common.DataColumnMapping _ (&quot;zip&quot;, &quot;zip&quot;), New System.Data.Common.DataColumnMapping(&quot;contract&quot;, &quot;contract&quot;)})}) Me.SqlDataAdapter1.UpdateCommand = Me.SqlUpdateCommand1 '       'SqlDeleteCommand1 '       Me.SqlDeleteCommand1.CommandText = &quot;DELETE FROM authors WHERE (au_id = @Original_au_id) AND (address = @Original_address OR &quot; & _            &quot;@Original_address IS NULL AND address IS NULL) AND (au_fname = @Original_au_fname) AND (au_lname = @Original_au_lname) &quot; & _ &quot;AND (city = @Original_city OR @Original_city IS NULL AND city IS NULL) AND (contract = @Original_contract) AND &quot; & _ &quot;(phone = @Original_phone) AND (state = @Original_state OR @Original_state IS NULL AND state IS NULL) AND (zip = &quot; & _                       &quot;@Original_zip OR @Original_zip IS NULL AND zip IS NULL)&quot; Me.SqlDeleteCommand1.Connection = Me.SqlConnection1 Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@Original_au_id&quot;, System.Data.SqlDbType.VarChar, 11, _ System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), &quot;au_id&quot;, System.Data.DataRowVersion.Original, Nothing)) Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@Original_address&quot;, System.Data.SqlDbType.VarChar, 40, _ System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), &quot;address&quot;, System.Data.DataRowVersion.Original, Nothing)) Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@Original_au_fname&quot;, System.Data.SqlDbType.VarChar, 20, _ System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), &quot;au_fname&quot;, System.Data.DataRowVersion.Original, Nothing)) Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@Original_au_lname&quot;, System.Data.SqlDbType.VarChar, 40, _ System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), &quot;au_lname&quot;, System.Data.DataRowVersion.Original, Nothing)) Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@Original_city&quot;, System.Data.SqlDbType.VarChar, 20, _ System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), &quot;city&quot;, System.Data.DataRowVersion.Original, Nothing)) Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@Original_contract&quot;, System.Data.SqlDbType.Bit, 1, _ System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), &quot;contract&quot;, System.Data.DataRowVersion.Original, Nothing)) Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@Original_phone&quot;, System.Data.SqlDbType.VarChar, 12, _ System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), &quot;phone&quot;, System.Data.DataRowVersion.Original, Nothing)) Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@Original_state&quot;, System.Data.SqlDbType.VarChar, 2, _ System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), &quot;state&quot;, System.Data.DataRowVersion.Original, Nothing)) Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@Original_zip&quot;, System.Data.SqlDbType.VarChar, 5, _ System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), &quot;zip&quot;, System.Data.DataRowVersion.Original, Nothing)) '       'SqlInsertCommand1 '       Me.SqlInsertCommand1.CommandText = &quot;INSERT INTO authors(au_id, au_lname, au_fname, phone, address, city, state, zip, contract) &quot; & _ &quot;VALUES (@au_id, @au_lname, @au_fname, @phone, @address, @city, @state, @zip, @contract); SELECT au_id, au_lname, au_fname, &quot; & _ &quot;phone, address, city, state, zip, contract FROM authors WHERE (au_id = @au_id)&quot; Me.SqlInsertCommand1.Connection = Me.SqlConnection1 Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@au_id&quot;, System.Data.SqlDbType.VarChar, 11, &quot;au_id&quot;)) Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@au_lname&quot;, System.Data.SqlDbType.VarChar, 40, &quot;au_lname&quot;)) Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@au_fname&quot;, System.Data.SqlDbType.VarChar, 20, &quot;au_fname&quot;)) Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@phone&quot;, System.Data.SqlDbType.VarChar, 12, &quot;phone&quot;)) Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@address&quot;, System.Data.SqlDbType.VarChar, 40, &quot;address&quot;)) Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@city&quot;, System.Data.SqlDbType.VarChar, 20, &quot;city&quot;)) Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@state&quot;, System.Data.SqlDbType.VarChar, 2, &quot;state&quot;)) Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@zip&quot;, System.Data.SqlDbType.VarChar, 5, &quot;zip&quot;)) Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@contract&quot;, System.Data.SqlDbType.Bit, 1, &quot;contract&quot;)) '       'SqlSelectCommand1 '       Me.SqlSelectCommand1.CommandText = &quot;SELECT au_id, au_lname, au_fname, phone, address, city, state, zip, contract FROM authors&quot; Me.SqlSelectCommand1.Connection = Me.SqlConnection1 '       'SqlUpdateCommand1 '       Me.SqlUpdateCommand1.CommandText = &quot;UPDATE authors SET au_id = @au_id, au_lname = @au_lname, au_fname = @au_fname, phone = &quot; & _ &quot;@phone, address = @address, city = @city, state = @state, zip = @zip, contract = @contract WHERE (au_id = @Original_au_id) &quot; & _ &quot;AND (address = @Original_address OR @Original_address IS NULL AND address IS NULL) AND (au_fname = @Original_au_fname) &quot; & _ &quot;AND (au_lname = @Original_au_lname) AND (city = @Original_city OR @Original_city IS NULL AND city IS NULL) AND &quot; & _ &quot;(contract = @Original_contract) AND (phone = @Original_phone) AND (state = @Original_state OR @Original_state IS &quot; & _                           &quot;NULL AND state IS NULL) AND (zip = @Original_zip OR @Original_zip IS NULL AND zip IS NULL); SELECT au_id, &quot; & _ &quot;au_lname, au_fname, phone, address, city, state, zip, contract FROM authors WHERE (au_id = @au_id)&quot; Me.SqlUpdateCommand1.Connection = Me.SqlConnection1 Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@au_id&quot;, System.Data.SqlDbType.VarChar, 11, &quot;au_id&quot;)) Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@au_lname&quot;, System.Data.SqlDbType.VarChar, 40, &quot;au_lname&quot;)) Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@au_fname&quot;, System.Data.SqlDbType.VarChar, 20, &quot;au_fname&quot;)) Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@phone&quot;, System.Data.SqlDbType.VarChar, 12, &quot;phone&quot;)) Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@address&quot;, System.Data.SqlDbType.VarChar, 40, &quot;address&quot;)) Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@city&quot;, System.Data.SqlDbType.VarChar, 20, &quot;city&quot;)) Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@state&quot;, System.Data.SqlDbType.VarChar, 2, &quot;state&quot;)) Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@zip&quot;, System.Data.SqlDbType.VarChar, 5, &quot;zip&quot;)) Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@contract&quot;, System.Data.SqlDbType.Bit, 1, &quot;contract&quot;)) Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@Original_au_id&quot;, System.Data.SqlDbType.VarChar, 11, _ System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), &quot;au_id&quot;, System.Data.DataRowVersion.Original, Nothing)) Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@Original_address&quot;, System.Data.SqlDbType.VarChar, 40, _ System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), &quot;address&quot;, System.Data.DataRowVersion.Original, Nothing)) Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@Original_au_fname&quot;, System.Data.SqlDbType.VarChar, 20, _ System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), &quot;au_fname&quot;, System.Data.DataRowVersion.Original, Nothing)) Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@Original_au_lname&quot;, System.Data.SqlDbType.VarChar, 40, _ System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), &quot;au_lname&quot;, System.Data.DataRowVersion.Original, Nothing)) Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@Original_city&quot;, System.Data.SqlDbType.VarChar, 20, _ System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), &quot;city&quot;, System.Data.DataRowVersion.Original, Nothing)) Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@Original_contract&quot;, System.Data.SqlDbType.Bit, 1, _ System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), &quot;contract&quot;, System.Data.DataRowVersion.Original, Nothing)) Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@Original_phone&quot;, System.Data.SqlDbType.VarChar, 12, _ System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), &quot;phone&quot;, System.Data.DataRowVersion.Original, Nothing)) Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@Original_state&quot;, System.Data.SqlDbType.VarChar, 2, _ System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), &quot;state&quot;, System.Data.DataRowVersion.Original, Nothing)) Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter(&quot;@Original_zip&quot;, System.Data.SqlDbType.VarChar, 5, _ System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), &quot;zip&quot;, System.Data.DataRowVersion.Original, Nothing)) '       'Button1 '       Me.Button1.Location = New System.Drawing.Point(88, 56) Me.Button1.Name = &quot;Button1&quot; Me.Button1.TabIndex = 0 Me.Button1.Text = &quot;Button1&quot; '       'Dataset11 '       Me.Dataset11.DataSetName = &quot;Dataset1&quot; Me.Dataset11.Locale = New System.Globalization.CultureInfo(&quot;en-US&quot;) '       'Form1 '       Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.Add(Me.Button1) Me.Name = &quot;Form1&quot; Me.Text = &quot;Form1&quot; CType(Me.Dataset11, System.ComponentModel.ISupportInitialize).EndInit Me.ResumeLayout(False)

End Sub


 * 1) End Region

End Class </li> On the Build menu, click Build Solution.</li></ol>

Add an inherited Windows form to the project
<ol> In Solution Explorer, click the WindowsApplication project.</li> On the Project menu, click Add Inherited Form.</li> In the Add New Item - WindowsApplication dialog box, click Inherited Form under Templates.</li> Click Open.</li> In the Inheritance Picker dialog box, click Form1 under Component Name.</li> Click OK. By default, the Form2.vb Windows form is created.</li>  In the Code view of the Form2.vb Windows form, replace the existing code with the following code: Public Class Form2 Inherits WindowsApplication.Form1 Public Sub New MyBase.New 'This call is required by the Windows Form Designer. InitializeComponent 'Add any initialization after the InitializeComponent call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose End If       End If        MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough> Private Sub InitializeComponent components = New System.ComponentModel.Container CType(Me.Dataset11, System.ComponentModel.ISupportInitialize).BeginInit CType(Me.Dataset11.authors, System.ComponentModel.ISupportInitialize).BeginInit '       'DataSet11 '       '        'DataSet11.authors '       Me.Dataset11.authors.Constraints.AddRange(New System.Data.Constraint _            {New System.Data.UniqueConstraint(&quot;Constraint1&quot;, New String {&quot;au_id&quot;}, True)}) Me.Dataset11.authors.TableName = &quot;authors&quot; '       'Form2 '       Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Name = &quot;Form2&quot; CType(Me.Dataset11.authors, System.ComponentModel.ISupportInitialize).EndInit CType(Me.Dataset11, System.ComponentModel.ISupportInitialize).EndInit End Sub End Class </li></ol>
 * 1) Region &quot; Windows Form Designer generated code &quot;
 * 1) End Region

Add code to create an instance of the inherited Windows form
<ol> In Solution Explorer, double-click Form1.vb. The Design view of the Form1.vb Windows form appears.</li> Double-click Button1.</li>  Add the following code to the Button1_Click event handler: Dim f As New Form2 f.Show </li></ol>

Add code to fill the dataset, and then run your application
<ol> In Design view of the Form1.vb Windows form, double-click Form1.</li>  Add the following code to the Form1_Load event handler: SqlDataAdapter1.Fill(DataSet11) </li> <li>On the Build menu, click Build Solution.</li> <li>On the Debug menu, click Start. The Form1 Windows form appears.</li> <li>Click Button1. You notice the behavior that is mentioned in the &quot;Symptoms&quot; section.</li></ol>

<div class="references_section">