PC Review


Reply
Thread Tools Rate Thread

detect FK in dataTable

 
 
Emre DİNÇER
Guest
Posts: n/a
 
      26th Nov 2007
Dear All,
is it possible to extract the DataColumn which is a foreign key of another
table. The DataTable has only one table.

foreach (DataRelation dr in dsIlce.Tables[0].ParentRelations) {

Console.WriteLine("123");

console.WriteLine(dr.ParentTable.TableName.ToString());

}

prints nothing unfortunately..



 
Reply With Quote
 
 
 
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      26th Nov 2007
Hi,


--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Emre DİNÇER" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Dear All,
> is it possible to extract the DataColumn which is a foreign key of another
> table. The DataTable has only one table.


I do not understand the above, The DataRelation has all the properties you
need for knowing the parent/child tables and columns.

Are you sure you have a FK ?


 
Reply With Quote
 
Nicholas Paldino [.NET/C# MVP]
Guest
Posts: n/a
 
      26th Nov 2007
Emre,

I think you mean the DataSet only has one table.

The DataRelation instances that are exposed by the DataSet class are the
in-memory representations of the relations between the DataTable instances.
Unless they are constructed and placed in the data set, they won't be there.
Usually, the designer will create the relations between the data tables for
you when you drag and drop tables from the server explorer to the data set
designer.

However, since you say you only have one data table in the data set, I
don't see how you can have any relations represented locally, because you
don't have another data table to relate to.

That being said, if you need relation information from the database, you
are going to have to query the database for it.


--
- Nicholas Paldino [.NET/C# MVP]
- (E-Mail Removed)

"Emre DİNÇER" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Dear All,
> is it possible to extract the DataColumn which is a foreign key of another
> table. The DataTable has only one table.
>
> foreach (DataRelation dr in dsIlce.Tables[0].ParentRelations) {
>
> Console.WriteLine("123");
>
> console.WriteLine(dr.ParentTable.TableName.ToString());
>
> }
>
> prints nothing unfortunately..
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the best way to make a DataTable thread safe? DataTable.AcceptChanges() will throw exception (not documented) Ryan Liu Microsoft C# .NET 3 7th Jun 2006 05:07 PM
Detect Changes to maually built DataTable Joe Microsoft C# .NET 2 25th Apr 2006 05:35 AM
how to detect double click on the tabel cell of DataTable Maulin Vasavada Microsoft C# .NET 3 5th Feb 2005 10:35 AM
Detect each column's data type of SalDataReader, DataSet, DataTable Hardy Wang Microsoft ADO .NET 5 27th Feb 2004 03:48 PM
Detect each column's data type of SalDataReader, DataSet, DataTable Hardy Wang Microsoft C# .NET 5 27th Feb 2004 03:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:42 AM.