Page 1 of 1

Retrieving Metadata - Foreign Keys

Posted: Sat 04 Feb 2006 17:30
by nuntio
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

Constraints

Posted: Sat 04 Feb 2006 18:00
by nuntio
Please show me also how to retrieve Constraints.

Thx,
Nunzio

Posted: Mon 06 Feb 2006 08:29
by Serious
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)?

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

Posted: Mon 06 Feb 2006 17:37
by nuntio2000
Hi,
I suppose that my copy of MySQLDirect.NET 2.8 doesn't support "ForeignKeys" in the GetSchema() parameters.

Thank you,
Nunzio

Posted: Tue 07 Feb 2006 07:28
by Serious
You're right, this collection (and some others) was supported in MySQLDirect .NET 3.