Getting Table Definiton,RelationShip,Index ..etc

  • Thread starter Thread starter Ozz
  • Start date Start date
O

Ozz

I have Master Table(master) and Detail Table(detail)

How can i get master and detail table definition (columns
,indexes,key,etc..)
I know only name of the master and detail table ..
And i dont know relation between two table..

Only thing that i know is Tables' name....

by INFORMATION_SCHEMA.xxxx (in SQL server ) i can access information but it
is not easy..
in ADO.NET how can I do this easily..
I want XMLDocument like that ...

<a>
<table name=master>
<column index="true" PK="true" name="ID" type="int" />
<column index="true" PK="false" name="DetailId type="int">
<table name="detail">
<column index="true" PK="true" name="DetailId"
type="int" />
<column index="true" PK="false" name="DetailName"
type="nvarchar(30)" />
</table>
/column>
</a>
 
look into the GetSchemaTable Methods--- think it'll do what you want.

Retrieving Data Using the DataReader
http://msdn.microsoft.com/library/d...-us/cpguide/html/cpcontheadonetdatareader.asp

IDataReader.GetSchemaTable Method
http://msdn.microsoft.com/library/d...emDataIDataReaderClassGetSchemaTableTopic.asp

NOTE: This topic includes a complete list of the columns in the returned
DataTable.

OleDbDataReader.GetSchemaTable Method
http://msdn.microsoft.com/library/d...DbOleDbDataReaderClassGetSchemaTableTopic.asp

SqlDataReader.GetSchemaTable Method
http://msdn.microsoft.com/library/d...ientSqlDataReaderClassGetSchemaTableTopic.asp
 
I examined links that you sent..
you can get columns properties but you cant get relationship between two
tables....
I think i couldnt this information easily ....
We can get columns properties by using reader or INFORMATION_SCHEMA(sql
Server)
but we couldnt get relationship between tables or indexes easily..
 
Hi.

i had the same requirement and i wrote the complete set of Data Layer for retriving the required schema info such as tables, columns, pk's, fk's, ....... diff is i used Oracle as DB.

Rajeev
 
Back
Top