如何在ADOX中判断一个表是否存在?

chenyingshu 2009-04-26 02:22:33
如题。最近在做数据库
...全文
90 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenyingshu 2009-04-26
  • 打赏
  • 举报
回复
正在测试中....晚上来结贴。biweilun稍安勿躁
biweilun 2009-04-26
  • 打赏
  • 举报
回复
HoHo,上个星期刚答过的帖子,把代码翻了出来

#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("制定的表存在");
}


4,011

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧