龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > VC开发 >

获取ACCESS2000数据库中的所有表的名称(vc + ado)(2)

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
//打印错误代码及描述 void PrintProviderError(_ConnectionPtr pConnection) { ErrorPtr pErr = NULL; if( (pConnection-Errors-Count) 0) { long nCount = pConnection-Errors-Count; // Collection rang

//打印错误代码及描述

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 %s", pErr->Number, pErr->Description);
   AfxMessageBox(strError);
        }
    }
}

//打印COM的错误信息

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 Code meaning = %s",(LPCSTR) bstrDescription, e.ErrorMessage());
 AfxMessageBox(strError);

调用方法:

 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() )
 {

  m_strList.ResetContent();
  strFileName = dlg.GetPathName();
  lstrcpy(FileName,strFileName);
  OpenSchemaX(FileName);
 } 

释放部分:

LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
 // TODO: Add your specialized code here and/or call the base class
 switch(message) {
 case WM_CLOSE:
  CoUninitialize(); 
  break;
 default:
  break;
 }
 return CDialog::WindowProc(message, wParam, lParam);
}

调试环境:

WIN2000 + ADO + ACCESS2000 + VSP5

精彩图集

赞助商链接