Page 1 of 1

DataTable.PrimaryKeys

Posted: Tue 04 Apr 2006 17:16
by inTrance
Hello!

Is there any possibility to force MySQLDirect to fill in properties like DataTable.PrimaryKeys or DataColumn.AutoIncrement? I think this is more comfortable than using GetSchema.

// Edit: And when I have to use GetSchema: Does it work with all MySQL server systems ranging from 3.x to 5.x?

Kind Regards,

Florian Heinemann

Posted: Wed 05 Apr 2006 13:35
by Alexey
You may use FillSchema method of MySqlDataAdapter. See the code snippet below:

Code: Select all

      DataTable myTable = new DataTable();
      mySqlDataAdapter1.FillSchema(myTable, SchemaType.Source);
      for (int i = 0; i < myTable.Columns.Count; i++)
         MessageBox.Show(myTable.Columns[i].AutoIncrement.ToString());
or

Code: Select all

      for (int i = 0; i < myTable.PrimaryKey.Length; i++)
        MessageBox.Show(myTable.PrimaryKey[i].ToString());
Note that you'll have to configure mySqlDataAdapter1 before using it.