EDN Admin
Well-known member
<p style="margin:0cm 0cm 10pt <span style="font-size:small <span style="font-family:Calibri Title: Why canât I display two relational tables on the same form!
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small
<p style="margin:0cm 0cm 10pt <span style="font-size:small <span style="font-family:Calibri Hi,
<p style="margin:0cm 0cm 10pt <span style="font-size:small <span style="font-family:Calibri I created two tables and related them but I canât display them using grid view on the form.
<p style="margin:0cm 0cm 10pt <span style="text-decoration:underline <span style="font-size:small <span style="font-family:Calibri This is what I did using Visual C# 2010 Express:
<p style="margin:0cm 0cm 10pt <span style="font-size:small <span style="font-family:Calibri Created a database named Employees.mdf with two tables using Visual Studio IDE:
<p style="text-indent:-18pt; margin:0cm 0cm 0pt 54pt <span><span><span style="font-family:Calibri; font-size:small -<span style="font:7pt Times New Roman
<span style="font-size:small <span style="font-family:Calibri Table-1: Employee Info, named employeeInfo, key is EmployeeID. Has employee information but no addresses
<p style="text-indent:-18pt; margin:0cm 0cm 10pt 54pt <span><span><span style="font-family:Calibri; font-size:small -<span style="font:7pt Times New Roman
<span style="font-size:small <span style="font-family:Calibri Table-2: Employee addresses, named employeeAdress, Key is AddressID, EmployeeID as foreign key. Has several addresses per employee
<p style="margin:0cm 0cm 10pt <span style="font-size:small <span style="font-family:Calibri Set the relation using the Database Diagram within the Database Explorer:
<p style="text-indent:-18pt; margin:0cm 0cm 10pt 54pt <span><span><span style="font-family:Calibri; font-size:small -<span style="font:7pt Times New Roman
<span style="font-family:Calibri <span style="font-size:small Key employeeID in EmployeeInfo table related to EmployeeID in EmployeeAdress table
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri <span style="font-size:small Created a data set called EmployeeDataSet using the data source view connected to the database EmployeesConnectionString, and added the objects Tables.
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri <span style="font-size:small Dragged the tables EmployyesInfo and EmployeeAddress from the Source view to Form3
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri <span style="font-size:small Builded the solution with no error
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri <span style="font-size:small Ran the application and the EmployeeAddress table does not show relation to the EmployeeInfo table.
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri <span style="font-size:small I modify the relation within the Data Source View from âRelation Onlyâ to âBoth Relation and Foreign Key Constraintâ
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri <span style="font-size:small Build the application with no error
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri <span style="font-size:small When I ran the application and start the form I get an error as listed below at the end of this message
<p style="margin:0cm 0cm 10pt <span style="font-family:Tahoma,sans-serif <span style="font-size:small Can someone tell me how do I fix the problem so that I can do the following:
<p style="text-indent:-18pt; margin:0cm 0cm 0pt 54pt <span style="font-family:Tahoma,sans-serif <span><span style="font-size:small 1.<span style="font:7pt Times New Roman
<span style="font-family:Tahoma,sans-serif <span style="font-size:small Show both tables on the same form
<p style="text-indent:-18pt; margin:0cm 0cm 10pt 54pt <span style="font-family:Tahoma,sans-serif <span><span style="font-size:small 2.<span style="font:7pt Times New Roman
<span style="font-family:Tahoma,sans-serif <span style="font-size:small While I browse within the EmployeeInfo table the addresses related to this employee should show in the other table called EmployeeAddress
<p style="margin:0cm 0cm 10pt <span style="font-family:Tahoma,sans-serif <span style="font-size:small I would greatly appreciate your help.
<p style="margin:0cm 0cm 10pt <span style="font-family:Tahoma,sans-serif <span style="font-size:small Regards and have a great weekend.
<p style="margin:0cm 0cm 10pt <span style="font-family:Tahoma,sans-serif <span style="font-size:small Michael Najar
<p style="margin:0cm 0cm 10pt <span style="font-family:Tahoma,sans-serif
<pre>
Details:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
at System.Data.DataSet.EnableConstraints()
at System.Data.DataSet.set_EnforceConstraints(Boolean value)
at System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at EmployeesInfo.EmployeesDataSetTableAdapters.EmployeeAddressTableAdapter.Fill(EmployeeAddressDataTable dataTable) in GataVSDevDeskTopTier2CSEmployeesAdminEmployeesInfoEmployeesDataSet.Designer.cs:line 2193
at EmployeesInfo.Form3.Form3_Load(Object sender, EventArgs e) in GataVSDevDeskTopTier2CSEmployeesAdminEmployeesInfoForm3.cs:line 30
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
EmployeesAdmin
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///G:/Data/VSDev/DeskTop/Tier2/CS/EmployeesAdmin/EmployeesAdmin/bin/Release/EmployeesAdmin.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
EmployeesInfo
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///G:/Data/VSDev/DeskTop/Tier2/CS/EmployeesAdmin/EmployeesAdmin/bin/Release/EmployeesInfo.EXE
----------------------------------------
System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Data.DataSetExtensions
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Data.DataSetExtensions/v4.0_4.0.0.0__b77a5c561934e089/System.Data.DataSetExtensions.dll
----------------------------------------
System.Numerics
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Transactions
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
[/code]
<
Michael Najar wishes you great day<hr class="sig Michael Najar wishes you great day
View the full article
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small
<p style="margin:0cm 0cm 10pt <span style="font-size:small <span style="font-family:Calibri Hi,
<p style="margin:0cm 0cm 10pt <span style="font-size:small <span style="font-family:Calibri I created two tables and related them but I canât display them using grid view on the form.
<p style="margin:0cm 0cm 10pt <span style="text-decoration:underline <span style="font-size:small <span style="font-family:Calibri This is what I did using Visual C# 2010 Express:
<p style="margin:0cm 0cm 10pt <span style="font-size:small <span style="font-family:Calibri Created a database named Employees.mdf with two tables using Visual Studio IDE:
<p style="text-indent:-18pt; margin:0cm 0cm 0pt 54pt <span><span><span style="font-family:Calibri; font-size:small -<span style="font:7pt Times New Roman
<span style="font-size:small <span style="font-family:Calibri Table-1: Employee Info, named employeeInfo, key is EmployeeID. Has employee information but no addresses
<p style="text-indent:-18pt; margin:0cm 0cm 10pt 54pt <span><span><span style="font-family:Calibri; font-size:small -<span style="font:7pt Times New Roman
<span style="font-size:small <span style="font-family:Calibri Table-2: Employee addresses, named employeeAdress, Key is AddressID, EmployeeID as foreign key. Has several addresses per employee
<p style="margin:0cm 0cm 10pt <span style="font-size:small <span style="font-family:Calibri Set the relation using the Database Diagram within the Database Explorer:
<p style="text-indent:-18pt; margin:0cm 0cm 10pt 54pt <span><span><span style="font-family:Calibri; font-size:small -<span style="font:7pt Times New Roman
<span style="font-family:Calibri <span style="font-size:small Key employeeID in EmployeeInfo table related to EmployeeID in EmployeeAdress table
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri <span style="font-size:small Created a data set called EmployeeDataSet using the data source view connected to the database EmployeesConnectionString, and added the objects Tables.
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri <span style="font-size:small Dragged the tables EmployyesInfo and EmployeeAddress from the Source view to Form3
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri <span style="font-size:small Builded the solution with no error
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri <span style="font-size:small Ran the application and the EmployeeAddress table does not show relation to the EmployeeInfo table.
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri <span style="font-size:small I modify the relation within the Data Source View from âRelation Onlyâ to âBoth Relation and Foreign Key Constraintâ
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri <span style="font-size:small Build the application with no error
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri <span style="font-size:small When I ran the application and start the form I get an error as listed below at the end of this message
<p style="margin:0cm 0cm 10pt <span style="font-family:Tahoma,sans-serif <span style="font-size:small Can someone tell me how do I fix the problem so that I can do the following:
<p style="text-indent:-18pt; margin:0cm 0cm 0pt 54pt <span style="font-family:Tahoma,sans-serif <span><span style="font-size:small 1.<span style="font:7pt Times New Roman
<span style="font-family:Tahoma,sans-serif <span style="font-size:small Show both tables on the same form
<p style="text-indent:-18pt; margin:0cm 0cm 10pt 54pt <span style="font-family:Tahoma,sans-serif <span><span style="font-size:small 2.<span style="font:7pt Times New Roman
<span style="font-family:Tahoma,sans-serif <span style="font-size:small While I browse within the EmployeeInfo table the addresses related to this employee should show in the other table called EmployeeAddress
<p style="margin:0cm 0cm 10pt <span style="font-family:Tahoma,sans-serif <span style="font-size:small I would greatly appreciate your help.
<p style="margin:0cm 0cm 10pt <span style="font-family:Tahoma,sans-serif <span style="font-size:small Regards and have a great weekend.
<p style="margin:0cm 0cm 10pt <span style="font-family:Tahoma,sans-serif <span style="font-size:small Michael Najar
<p style="margin:0cm 0cm 10pt <span style="font-family:Tahoma,sans-serif
<pre>
Details:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
at System.Data.DataSet.EnableConstraints()
at System.Data.DataSet.set_EnforceConstraints(Boolean value)
at System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at EmployeesInfo.EmployeesDataSetTableAdapters.EmployeeAddressTableAdapter.Fill(EmployeeAddressDataTable dataTable) in GataVSDevDeskTopTier2CSEmployeesAdminEmployeesInfoEmployeesDataSet.Designer.cs:line 2193
at EmployeesInfo.Form3.Form3_Load(Object sender, EventArgs e) in GataVSDevDeskTopTier2CSEmployeesAdminEmployeesInfoForm3.cs:line 30
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
EmployeesAdmin
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///G:/Data/VSDev/DeskTop/Tier2/CS/EmployeesAdmin/EmployeesAdmin/bin/Release/EmployeesAdmin.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
EmployeesInfo
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///G:/Data/VSDev/DeskTop/Tier2/CS/EmployeesAdmin/EmployeesAdmin/bin/Release/EmployeesInfo.EXE
----------------------------------------
System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Data.DataSetExtensions
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Data.DataSetExtensions/v4.0_4.0.0.0__b77a5c561934e089/System.Data.DataSetExtensions.dll
----------------------------------------
System.Numerics
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Transactions
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
[/code]
<
Michael Najar wishes you great day<hr class="sig Michael Najar wishes you great day
View the full article