麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 數(shù)據(jù)庫 > Access > 正文

獲取ACCESS2000數(shù)據(jù)庫中所有表的名稱

2024-09-07 19:03:24
字體:
供稿:網(wǎng)友

void OpenSchemaX(TCHAR *TableName)
{
HRESULT hr = S_OK;

::CoInitialize(NULL); //初始化Com

IADORecordBinding *picRs = NULL;

_RecordsetPtr pRstSchema("ADODB.Recordset");
_ConnectionPtr pConnection("ADODB.Connection" );

pConnection->ConnectionString = TableName;
pConnection->Provider = "Microsoft.Jet.OLEDB.4.0";

try
{
pConnection->Open(pConnection->ConnectionString, "", "", adModeUnknown);
pRstSchema->QueryInterface(
__uuidof(IADORecordBinding), (LPVOID*)&picRs);

pRstSchema = pConnection->OpenSchema(adSchemaTables);//枚舉表的名稱處理

while(!(pRstSchema->EndOfFile))
{
CString strTableType;

_bstr_t table_name = pRstSchema->Fields->
GetItem("TABLE_NAME")->Value;//獲取表的名稱

_bstr_t table_type = pRstSchema->Fields->
GetItem("TABLE_TYPE")->Value;//獲取表的類型

strTableType.Format("%s",(LPCSTR) table_type);

if(!lstrcmp(strTableType,_T("TABLE")))
{
m_strList.AddString((LPCSTR) table_name);//添加表的名稱
}

pRstSchema->MoveNext();
}
// Clean up objects before exit.

pRstSchema->Close();
pConnection->Close();
}

catch (_com_error &e)
{
// Notify the user of errors if any.
// Pass a connection pointer accessed from the Connection.
PrintProviderError(pConnection);
PrintComError(e);
}
CoUninitialize();
}

void PrintProviderError(_ConnectionPtr pConnection)
{
ErrorPtr pErr = NULL;

if( (pConnection->Errors->Count) > 0)
{
long nCount = pConnection->Errors->Count;
// Collection ranges from 0 to nCount -1.
for(long i = 0;i < nCount;i )
{
pErr = pConnection->Errors->GetItem(i);
CString strError;
strError.Format("Error number: %x/t%s", pErr->Number, pErr->Description);
AfxMessageBox(strError);
}
}
}

void PrintComError(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());

// Print COM errors.
CString strError;
strError.Format("Error number: Description = %s/tCode meaning = %s",(LPCSTR) bstrDescription, e.ErrorMessage());
AfxMessageBox(strError);
}

調(diào)用方法:

CString strFileName;
TCHAR FileName[MAX_PATH];
TCHAR bigBuff[2048] = _T(""); // maximum common dialog buffer size
TCHAR szFilter[] = _T("Text Files (*.mdb)|*.mdb|All Files (*.*)|*.*
");
CFileDialog dlg(TRUE, NULL, NULL,
OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT, szFilter);

// Modify OPENFILENAME members directly to point to bigBuff
dlg.m_ofn.lpstrFile = bigBuff;
dlg.m_ofn.nMaxFile = sizeof(bigBuff);

if(IDOK == dlg.DoModal() )
{
strFileName = dlg.GetPathName();
lstrcpy(FileName,strFileName);
OpenSchemaX(FileName);
}(出處:風(fēng)閃網(wǎng)路學(xué)院)

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 欧美一区二区三区免费不卡 | chinesehd天美原创xxxx | 第一区免费在线观看 | 青热久思思 | 99国产精品国产免费观看 | 国产精品久久久久久影院8一贰佰 | 国产一区二区三区网站 | 视频在线91 | 午夜久久久精品一区二区三区 | aaaaa国产欧美一区二区 | 久久精品国产一区二区 | 看黄在线观看 | 中文字幕网址 | av资源在线天堂 | 亚洲成人免费影视 | 91精品国产92久久久久 | 久久成人精品视频 | 国产精品毛片va一区二区三区 | av之家在线观看 | 色妞妞视频 | 在线播放黄色网址 | 久久精品性视频 | 免费a级毛片大学生免费观看 | 午夜视频你懂的 | 成年免费在线视频 | 一区在线免费视频 | 久草在线新时代视觉 | 欧美伦交 | 暴力肉体进入hdxxxx0 | 万圣街在线观看免费完整版 | 欧美激情999 | 一级黄色免费电影 | 一级大黄毛片 | 午夜色视频在线观看 | 男女羞羞视频在线观看免费 | 一级免费观看 | 国产精品啪 | 国产精品一区久久久久 | 亚洲男人的天堂在线视频 | av免费入口| 欧美日韩综合视频 |