Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / October 2004

Tip: Looking for answers? Try searching our database.

Column must belong to a table?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paschalis Pagonidis - 21 Oct 2004 09:28 GMT
Hi to all,

I get this ArgumentException just when:
((System.ComponentModel.ISupportInitialize)
(this.dataTable2)).EndInit();

runs inside InitializeComponent()...

It raises when I set primary key on the table:

The code I use is:
this.dataTable2.Columns.AddRange(new System.Data.DataColumn
[] {this.dataColumn3, this.dataColumn4});

this.dataTable2.Constraints.AddRange(new
System.Data.Constraint[] {
  new System.Data.UniqueConstraint("Constraint1", new
string[] {"dm_dpt_id", "dm_mod_id"}, true)});

this.dataTable2.PrimaryKey = new System.Data.DataColumn[] {
this.dataColumn3, this.dataColumn4};

this.dataTable2.TableName = "dm";

this.dataColumn3.AllowDBNull = false;
this.dataColumn3.ColumnName = "dm_dpt_id";
this.dataColumn3.DataType = typeof(int);

this.dataColumn4.AllowDBNull = false;
this.dataColumn4.ColumnName = "dm_mod_id";
this.dataColumn4.DataType = typeof(int);

Table dm:
+---------------------+
|         dm          |
+---------------------+
| PK int(4) dm_dpt_id |
| PK int(4) dm_mod_id |
+---------------------+
Scave - 22 Oct 2004 01:36 GMT
Hi,

I just tried out the following test example and no exceptions were
thrown:
   DataTable table1 = new DataTable();
   DataColumn[] primaryKeyCols = new DataColumn[] {new
DataColumn("Col 1"), new DataColumn("Col 2")};
   table1.Columns.AddRange(primaryKeyCols);
   table1.PrimaryKey = primaryKeyCols;

The result is a DataTable with one Unique Constraint between "Col 1"
and "Col 2" which is also the primary key.
Is there something I'm failing to do that your code requires?

> Hi to all,
>
[quoted text clipped - 35 lines]
> | PK int(4) dm_mod_id |
> +---------------------+
Paschalis Pagonidis - 22 Oct 2004 09:25 GMT
Hmm, the concept is the same. You create two fields,
assign them to table1 and make them primary keys.

There is something that causes the compiler to "complain".
For the moment I removed the constraint and I manage it by
hand, until I finish with the remaining code...

Thanks anyway...

>-----Original Message-----
>Hi,
[quoted text clipped - 12 lines]
>
>"Paschalis Pagonidis" <anonymous@discussions.microsoft.com> wrote in message
news:<032d01c4b747$e243ed40$a601280a@phx.gbl>...
>> Hi to all,
>>
[quoted text clipped - 36 lines]
>> +---------------------+
>.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.