用以下代码可以实现:
//TableName是要查询的表名。通过检索数据库中的表名来确定TableName是否存在。
//也就是列举数据库的表。
try
{
_RecordsetPtr pRstSchema = NULL;
pRstSchema = m_pConnection->OpenSchema(adSchemaTables);
while(!(pRstSchema->AdoEOF))
{
if(TableName == (_bstr_t)pRstSchema->Fields->GetItem("TABLE_NAME")->Value)
{
pRstSchema->Close();
return TRUE;
}
pRstSchema->MoveNext();
}
return FALSE;
}
catch (_com_error &e)
{
AfxMessageBox("获取表名出错!");
return FALSE;
}
//TableName是要查询的表名。通过检索数据库中的表名来确定TableName是否存在。
//也就是列举数据库的表。
try
{
_RecordsetPtr pRstSchema = NULL;
pRstSchema = m_pConnection->OpenSchema(adSchemaTables);
while(!(pRstSchema->AdoEOF))
{
if(TableName == (_bstr_t)pRstSchema->Fields->GetItem("TABLE_NAME")->Value)
{
pRstSchema->Close();
return TRUE;
}
pRstSchema->MoveNext();
}
return FALSE;
}
catch (_com_error &e)
{
AfxMessageBox("获取表名出错!");
return FALSE;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货