濮阳杆衣贸易有限公司

主頁 > 知識庫 > 獲取ACCESS2000數(shù)據(jù)庫中所有表的名稱

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

熱門標簽:機器人電話機創(chuàng)意繪畫 天音通信電話機器人 杭州400電話如何申請的 高德地圖標注商家在哪 江西南昌百應電話機器人 400電話從哪里申請濱州 隨州營銷電話機器人怎么樣 400電話申請怎么看 hbuilder地圖標注

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);
}(出處:風閃網(wǎng)路學院)

標簽:昆明 鶴崗 常德 招商 石嘴山 葫蘆島 保定 沈陽

巨人網(wǎng)絡通訊聲明:本文標題《獲取ACCESS2000數(shù)據(jù)庫中所有表的名稱》,本文關(guān)鍵詞  獲取,ACCESS2000,數(shù)據(jù)庫,中,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《獲取ACCESS2000數(shù)據(jù)庫中所有表的名稱》相關(guān)的同類信息!
  • 本頁收集關(guān)于獲取ACCESS2000數(shù)據(jù)庫中所有表的名稱的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    万宁市| 鄂温| 栾川县| 叶城县| 辽宁省| 丰城市| 加查县| 祁门县| 泰安市| 密云县| 永德县| 肃北| 繁昌县| 木里| 清丰县| 韶关市| 常宁市| 滨州市| 同心县| 包头市| 分宜县| 隆昌县| 泸水县| 观塘区| 治县。| 奈曼旗| 揭东县| 乌苏市| 喀喇| 博野县| 南木林县| 奉节县| 常熟市| 哈巴河县| 新竹市| 治县。| 鄂托克前旗| 秦皇岛市| 安吉县| 闽清县| 固始县|