| 学习资料 —> IT类 —> 计算机等级
 
获取ACCESS2000数据库中所有表的名称(二)
(发布时间:2007-6-8 16:25:00 来自:模考网)

  // 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\ts, 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);

  }

  调用方法:

  CString strFileName;

  TCHAR FileName[MAX_PATH];

  TCHAR bigBuff[2048] = _T(); // maximum common dialog buffer size

  TCHAR szFilter[] = _T(Text Files (*.mdb)|*.mdb|All Files (*.*)|*.*

  );

[上一页] [1] [2] [3] [下一页]

 

收藏此页】【字体: 】【打印】【关闭