Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ADO

ADO

Scheduled Pinned Locked Moved C / C++ / MFC
databasetutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yingkou
    wrote on last edited by
    #1

    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

    B 1 Reply Last reply
    0
    • Y yingkou

      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

      B Offline
      B Offline
      BlackDice
      wrote on last edited by
      #2

      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

      Y 1 Reply Last reply
      0
      • B 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

        Y Offline
        Y Offline
        yingkou
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups