View Code
if (CoInitialize(NULL)!=0) 
 { 
  AfxMessageBox("初始化COM支持库失败!"); 
  exit(1); 
 } 
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
 try
 {
  CString strConnect;
  strConnect.Format("DSN=mystudentsys;");
  if (m_DB.Open(NULL,false,false,"ODBC;DSN=mystudentsys;UID=Sa;PWD=HPSQL2005;",false)==0)
  {
   AfxMessageBox("Unable to Connect to the Specified Data Source");
   return FALSE ;
  }
 }
 catch(CDBException *pE)
 {
  pE->ReportError();
  pE->Delete();
  return FALSE;
 }

 

posted on 2012-07-21 10:40  world_ding  阅读(556)  评论(0编辑  收藏  举报