![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
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; }