473,320 Members | 1,600 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

detect FK in dataTable

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.ToStrin g());

}

prints nothing unfortunately..

Nov 26 '07 #1
2 1358
Hi,
--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Emre DİNÇER" <ed*****@meteksan.com.trwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
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 ?
Nov 26 '07 #2
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]
- mv*@spam.guard.caspershouse.com

"Emre DİNÇER" <ed*****@meteksan.com.trwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
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.ToStrin g());

}

prints nothing unfortunately..

Nov 26 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: jim | last post by:
This line of code returns error 13, cast from 'DBNull' to type 'String' is not valid If IsDBNull(Clinics.Clinics.Item(A).Workphone) The <other code End I Clinics.Clinics is a dataset that...
5
by: Hardy Wang | last post by:
Hi all, I am just wandering, is it possible to programmatically detect each column's data type of SalDataReader, DataSet.Tables, DataTable? Thanks for any suggestion! -- WWW:...
3
by: Maulin Vasavada | last post by:
Hi, I have DataTable and I want to actually put a LinkLabel in one the columns where I can click an do something BUT it seems I can't put LinkLabel in the table cell of DataTable. So as an...
1
by: Bob | last post by:
I am developing a database app using vb.net and SQL Server. I am trying to come up with a way I can detect if the user has made any changes/updates to any data currently displayed on the form so that...
2
by: eBob.com | last post by:
I've got the basics of an XML ini file working. I.E. I can stash away and retrieve user preferences. (Code below.) But how do I handle a new preference? Say I have A and B. And then I invent...
4
by: keithb | last post by:
What is the correct syntax to detect whether a DataTable Row.ItemArray element is a null value? using: if (row.ItemArray == null ) does not seem to work. Thanks,
2
by: Joe | last post by:
Hi I am building a datatable manually and putting in a grid I would like to edit a row then determine that the table has changes and needs to be saved The problem I am having is that all...
2
by: Brian Tkatch | last post by:
How do i detect a datagrid row change? Currently, i have a few datagrids that i keep in sync, refreshing from the database whenver a row changes. I would like to avoid CurrentCellChanged because...
5
by: Doug Bell | last post by:
Hi I have a DataGrid that has a DataView as its DataSource. I need to detect when a New Row is added or when a Row is Deleted so that I change data in the underlying DataTable. I found that...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.