MichaelvdV@Atos

Get PI OLEDB tables list

Discussion created by MichaelvdV@Atos on Feb 5, 2010
Latest reply on Feb 6, 2010 by MichaelvdV@Atos

I need to get a list of all PI OLEDB tables (including the catalog name). Currently I am using the following code, but this only returns the tables from the piarchive catalog. (Code from a MSDN example).

 

How do I get all the OLEDB tables ?

 

 

 List<string> tables = new List<string>();

using (OleDbConnection conn = new OleDbConnection(
          string.Format("Provider = {0} ; Data Source = {1} ; User ID = {2}; Password = {3}; Session ID = -1;",
                             "PIOLEDB",
                             "HAL9K-PC",
                             "xxxxxxx",
                             "xxxxxxx")))
{
    conn.Open();
    string[] restrictions = new string[4];
    restrictions[3] = "Table";

    DataTable schemaTable = conn.GetSchema("Tables", restrictions);

    foreach (DataRow row in schemaTable.Rows)
        tables.Add(row["TABLE_NAME"].ToString());
}

return tables;

Outcomes