4,011
社区成员
发帖
与我相关
我的任务
分享
#include <adoint.h> #include <adoctint.h>
#include <comdef.h>
#include <shwapi.h>
#pragma comment(lib, "comsupp.lib")
#pragma comment(lib, "shlwapi.lib")
CComPtr<ADOCatalog>Catalog;
HRESULT hr = Catalog.CoCreateInstance(L"ADOX.Catalog");
if (FAILED(hr))
{
throw _com_error(hr, NULL);
}
static const TCHAR szConnStr[] =
_T("Provider=Microsoft.Jet.OLEDB.4.0;")
_T("Data Source=C:\\TEST1.MDB;");
CComVariant varConn;
hr = Catalog->Create(CComBSTR(szConnStr), &varConn);
CComPtr<ADOTables>Tables = NULL;
Catalog->get_Tables(&Tables);
CComPtr<ADOTable>Table = NULL;
Tables->get_Item(CComVariant(_T("Table Name")), &Table);
if(Table!=NULL)
{
//MessageBox("制定的表存在");
}