Domanda

In SQL è possibile utilizzare

SELEZIONA * DA INFORMATION_SCHEMA.TABLES

ecc. per ottenere informazioni sulla struttura del database. Devo sapere come ottenere la stessa cosa per un database di Access.

È stato utile?

Soluzione

L'operazione equivalente può essere eseguita utilizzando

Metodo OleDbConnection.GetOleDbSchemaTable ().

vedi http://support.microsoft.com/kb/309488 per ulteriori informazioni

Altri suggerimenti

In OLEDB è possibile accedervi come DBSCHEMA_TABLES. Il seguente codice C ++ dimostra il recupero delle informazioni sulle tabelle da un provider OLEDB:

#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();
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top