Question

En SQL, vous pouvez utiliser

SELECT * FROM INFORMATION_SCHEMA.TABLES

etc. pour obtenir des informations sur la structure de la base de données. J'ai besoin de savoir comment obtenir la même chose pour une base de données Access.

Était-ce utile?

La solution

L'opération équivalente peut être accomplie avec

Méthode OleDbConnection.GetOleDbSchemaTable ().

voir http://support.microsoft.com/kb/309488 pour plus d'informations.

Autres conseils

Dans OLEDB, vous pouvez y accéder en tant que DBSCHEMA_TABLES. Le code C ++ suivant illustre la récupération des informations sur les tables à partir d’un fournisseur 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();
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top