Get table relations

  • Thread starter Thread starter garak
  • Start date Start date
G

garak

Hi,

I read the c# professional book from wrox and searched the internet.
I cant find any hint on how to get table realtion information out of
my database.
I know I can define relations in the dataset, but I want to read it
out of my ACCESS oder MSSQL-SERVER database, where it is already
defined.

Can anyone help (Suggestions, links, samples)

Thx
Frank
 
Frank,

Have a look at my reply in following thread : Re: Retrieving Access SQL
syntax

For Access I Suggest the same method with a different schema_Guid parameter.

For SQL-server you probably need to use another method based on
Information_schema . A search in MSDN with this keyword will give you all
the required info.

Regards,
Jan


garak said:
Hi,

I read the c# professional book from wrox and searched the internet.
I cant find any hint on how to get table realtion information out of
my database.
I know I can define relations in the dataset, but I want to read it
out of my ACCESS oder MSSQL-SERVER database, where it is already
defined.

Can anyone help (Suggestions, links, samples)

Thx
Frank
 
Hi,

You might try using OleDbConnection.GetOleDbSchemaTable method - it returns
you all sort of information.
If that doesn't work you'll have to resort either to AdoX (very similar to
the method above) or custom Sql stataments.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

garak said:
Hi,

I read the c# professional book from wrox and searched the internet.
I cant find any hint on how to get table realtion information out of
my database.
I know I can define relations in the dataset, but I want to read it
out of my ACCESS oder MSSQL-SERVER database, where it is already
defined.

Can anyone help (Suggestions, links, samples)

Thx
Frank
 
Hi,

thank you very much for your help.
How can I use SQL for this problem - What SQL-String do I have to use
?
This might be the right way when working with the SQL-Server.

Frank
 
Hi garak,

Check out the following stored procs:
sp_foreignkeys
sp_primarykeys
sp_tables

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

garak said:
Hi,

thank you very much for your help.
How can I use SQL for this problem - What SQL-String do I have to use
?
This might be the right way when working with the SQL-Server.

Frank
 
Back
Top