-1

How can I get index names for an Access table using OLEDB or SQL ?

(I searched a lot on the internet in the last two days and did not find anything related to this issue.)

4

1 回答 1

3

OleDbConnection 有一个名为GetSchema的方法,该方法接受一个字符串来选择要检索的元数据集合。

字符串参数的一些可能值是 Tables、Columns、Indexes

using(OleDbConnection cnn = new OleDbConnection("...."))
{
    cnn.Open();
    DataTable schemaIndexes = cnn.GetSchema("Indexes");
    foreach(DataRow row in schemaIndexes.Rows)
    {
       Console.WriteLine("Table={0}, Index={1} on field={2}",
           row.Field<string>("TABLE_NAME"),
           row.Field<string>("INDEX_NAME"),
           row.Field<string>("COLUMN_NAME"));
    }
}
于 2015-01-27T16:56:34.720 回答