连接sybase时候的一个问题
我是用VC6连接sybase
部分代码如下:
连接的字符串为:#define SYBASE_STRING "Provider=Sybase.ASEOLEDBProvider.2;Initial Catalog=%s;Password=%s;User ID=%s;Data Source=%s;Persist Security Info=True"m_pConnection.CreateInstance("ADODB.Connection"); m_strAdoConn.Format(SYBASE_STRING,strDBName,strPwd,strUID,strSerName); m_IsConnectionOpen = FALSE; if(m_pConnection != NULL) { HRESULT hr; try { m_pConnection->PutConnectionTimeout((long)5); hr = m_pConnection->Open(_bstr_t(m_strAdoConn) ,_bstr_t(L"") ,_bstr_t(L""),adModeUnknown); if (SUCCEEDED(hr)) { m_IsConnectionOpen = TRUE; TRACE("Êý¾Ý¿âÁ¬½Ó³É¹¦!"); return TRUE; } } catch( _com_error &e ) { //Get info from _com_error _bstr_t bstrSource(e.Source()); _bstr_t bstrDescription(e.Description()); [color=#FF0000]//此处捕获的异常为:Cannot open file 'C:\Sybase\OLEDB\192.169.1.115.ids'." (1)[/color] TRACE("cccException thrown for classes generated by #import"); TRACE("\tCode = %081x\n", e.Error()); TRACE("\tcode meaning = %s\n", e.ErrorMessage()); TRACE("\tSource = %s\n", (LPCTSTR)bstrSource); TRACE("\tDescription = %s\n", (LPCTSTR)bstrDescription); TRACE("++++++"); char sLog[1024]; sprintf(sLog, "%s%081x%s%s%s", "Exception thrown for classes generated by #import", e.Error(), e.ErrorMessage(), (LPCTSTR)bstrSource, (LPCTSTR)bstrDescription); } catch(...) { TRACE("*** unhandled Exception ***"); } }