Retrieving Metadata - Foreign Keys

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
nuntio

Retrieving Metadata - Foreign Keys

Post by nuntio » Sat 04 Feb 2006 17:30

Please help me to retrieve Foreign Keys.
This is my code to retrieve Primary Keys:

Code: Select all

private DataTable GetPrimaryKeys(string tablename) 
{
  conn.Open();
				
  DataTable schemaTable = new DataTable();

  schemaTable.PrimaryKey = conn.GetSchema("Columns", new string[] { "Test", tablename }).PrimaryKey;

  conn.Close();
		
  return schemaTable;
}

I have to write the same method in order to retrieve the Foreign Keys.
Thanks,
Nunzio

nuntio

Constraints

Post by nuntio » Sat 04 Feb 2006 18:00

Please show me also how to retrieve Constraints.

Thx,
Nunzio

Serious

Post by Serious » Mon 06 Feb 2006 08:29

To retrieve Foreign Keys metadata collection pass "ForeignKeys" string as parameter to GetSchema method call. This behavior is documented in "Retrieving Metadata" topic in MySQLDirect .NET documentation.

Please describe what constraints you want to retrieve in addition to foreign keys (ForeignKeys collection) and primary keys (PrimaryKeys collection)?

nuntio2000
Posts: 19
Joined: Fri 19 Nov 2004 18:51
Location: South Italy

MySQLDirect.NET 2.8 doesn't support "ForeignKeys" in the GetSchema()

Post by nuntio2000 » Mon 06 Feb 2006 17:37

Hi,
I suppose that my copy of MySQLDirect.NET 2.8 doesn't support "ForeignKeys" in the GetSchema() parameters.

Thank you,
Nunzio

Serious

Post by Serious » Tue 07 Feb 2006 07:28

You're right, this collection (and some others) was supported in MySQLDirect .NET 3.

Post Reply