What is the OleDb equivalent for INFORMATION_SCHEMA

In SQL you can use

SELECT * FROM INFORMATION_SCHEMA.TABLES

etc. to get information about the structure of the database. I need to know how to achieve the same for an Access database.

+3
source share
2 answers

An equivalent operation can be performed using

Method OleDbConnection.GetOleDbSchemaTable ().

see http://support.microsoft.com/kb/309488 for more information

+3
source

OLEDB can be accessed as DBSCHEMA_TABLES. The following C ++ code demonstrates retrieving table information from an OLEDB provider:

#include <atldb.h>
...
        // Standard way of obtaining table node info.
        CAccessorRowset<CDynamicAccessor, CBulkRowset> pRS;
        pRS.SetRows(100);

        CSchemaTables<CSession>* pBogus;
        hr = session.CreateSchemaRowset(NULL, 0, NULL, IID_IRowset, 0, NULL, (IUnknown**)&pRS.m_spRowset, pBogus);
        if (FAILED(hr))
            goto lblError;

        hr = pRS.Bind();
        if (FAILED(hr))
            goto lblError;

        hr = pRS.MoveFirst();
        if (FAILED(hr))
            goto lblError;

        while (S_OK == hr)
        {
            wstring sTableSchema(pRS.GetWCharValue(L"TABLE_SCHEMA"));
            wstring sTableName(pRS.GetWCharValue(L"TABLE_NAME"));
            wstring sTableType(pRS.GetWCharValue(L"TABLE_TYPE"));
            ...

            hr = pRS.MoveNext(); 
        }
        pRS.Close();
0
source

Source: https://habr.com/ru/post/1697354/


All Articles