ADO
-
I want to use method below to manapulate database:but how can I get the specified interface ,for example:_ConnectionPtr. IDispatch* pDispatch=NULL; CLSID clsid; CoInitialize(0); HRESULT hr = ::CLSIDFromProgID(L"ADODB.Connection", &clsid); if(FAILED(hr)){return;} CoCreateInstance(clsid, NULL, CLSCTX_SERVER, IID_IDispatch, (void **) &pDispatch); if(FAILED(hr)){return;} thanks a lot
-
I want to use method below to manapulate database:but how can I get the specified interface ,for example:_ConnectionPtr. IDispatch* pDispatch=NULL; CLSID clsid; CoInitialize(0); HRESULT hr = ::CLSIDFromProgID(L"ADODB.Connection", &clsid); if(FAILED(hr)){return;} CoCreateInstance(clsid, NULL, CLSCTX_SERVER, IID_IDispatch, (void **) &pDispatch); if(FAILED(hr)){return;} thanks a lot
Click on 'My Articles' link in my signature and go to my BugReporter article. See described in the article how I use #import to use ADO in my app, or look at the comments posted below my article on how to use LIBID (if you're using VC7). Better yet, BugReporter[^] My articles www.stillwaterexpress.com BlackDice
-
Click on 'My Articles' link in my signature and go to my BugReporter article. See described in the article how I use #import to use ADO in my app, or look at the comments posted below my article on how to use LIBID (if you're using VC7). Better yet, BugReporter[^] My articles www.stillwaterexpress.com BlackDice
thanks for your help,but I want to use this method without importing ado.dll: CString m_strConnect.Format("Provider=OraOLEDB.Oracle.1;Password=user_password;Persist Security Info=True;User ID=user_id;Data Source=user_DATASource;"); _RecordsetPtr m_prs; _ConnectionPtr m_pConnection; HRESULT hr = S_OK; try { hr = m_prs.CreateInstance(__uuidof(Recordset)); if(FAILED(hr)) { AfxMessageBox("记录集对象建立失败!",MB_ICONINFORMATION); return ; } BeginWaitCursor(); m_strSQL = "select * from tableA"; hr = m_prs->Open(_bstr_t(m_strSQL),(IDispatch*)m_pConnection,adOpenStatic ,adLockReadOnly,adCmdText); if(FAILED(hr)) { AfxMessageBox("数据库查询失败!",MB_ICONINFORMATION); return ; } EndWaitCursor(); } catch(_com_error e) { CString errormessage; errormessage.Format("错误信息:%s",(char*)(e.Description())); AfxMessageBox(errormessage, MB_ICONINFORMATION); return; } catch (CException err) { err.ReportError(); return; } catch(...) { AfxMessageBox("未知错误!",MB_ICONINFORMATION); return; } compiles show errors:_ConnectionPtr not definition