日期:2014-05-17 浏览次数:20721 次
bool ADOConn::OnInitADOConn() { #ifdef _LOG_DESTDOWNLOAD_ vos_util_demo_print( "ADOConn::OnInitADOConn() IN \n" ); #endif // 初始化OLE/COM库环境 if(FAILED(::CoInitialize(NULL))) return false; #ifdef _LOG_DESTDOWNLOAD_ vos_util_demo_print( "ADOConn::CoInitialize() SUCCESS \n" ); #endif try { if(FAILED(m_pConnection.CreateInstance( __uuidof( Connection ) ))) return false; #ifdef _LOG_DESTDOWNLOAD_ vos_util_demo_print( "m_pConnection.CreateInstance SUCCESS \n" ); #endif if(FAILED(m_pCommandPer.CreateInstance( __uuidof( Command ) ))) return false; #ifdef _LOG_DESTDOWNLOAD_ vos_util_demo_print( "m_pCommandPer.CreateInstance SUCCESS \n" ); #endif m_pRecordset = NULL; // 设置连接字符串,必须是BSTR型或者_bstr_t类型 _bstr_t strConnect = "Provider=OraOLEDB.Oracle.1; Data Source=tspora1;User ID=tsp;Password=tsp;Persist Security Info=True;"; if(FAILED(m_pConnection->Open( strConnect, "", "", adModeUnknown))) return false; #ifdef _LOG_DESTDOWNLOAD_ vos_util_demo_print( "m_pConnection->Open SUCCESS \n" ); #endif } // 捕捉异常 catch( _com_error e ) { return false; } return true; }