Reputation: 6037
Consider i have 'n' tables which are created using MS Access.
Now i need to find the relationship among the tables. i.e How the tables are interlinked as changes made in a table will be reflected other table.?
is there any to find this using c#
Upvotes: 0
Views: 2961
Reputation: 1
DataTable schemaTable =
oledbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Foreign_Keys,
new object[] {null, null, "OneTableName"});
or
DataTable schemaTable =
oledbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Foreign_Keys,
new object[] {null, null, "OneTableName", null, null, "OtherTableName"});
Upvotes: 0
Reputation: 23067
I don't believe you need to automate Access to do this. All that's needed, I think, is ADOX. This article shows how to use ADOX to copy relationships in VBA:
ACC2002: How to use ADOX to Import Relationships
Relationships are defined under the ADOX.Table.Keys property. I can't help you convert that to C#, but that code shows you what parts of the ADOX object model you need to use for this and ought to help you figure it out, I hope.
Upvotes: 0
Reputation: 1502
I am not sure how to find from C#. But in ms-access we can see easily find.
Open access database file. and click on Menu (Tools->Relationships). You can view the current relation ships.
Thanks and regards Haranadh
Upvotes: 3
Reputation: 115751
Either Google for MSysObjects
(see this, for instance) or use GetSchema on OleDbConnection
.
Upvotes: 1