谁能和我详细介绍一下MFC用ADO连接数据库的过程??????

解决方案 »

  1.   

    网上搜搜很多这类文章
    http://wenku.baidu.com/view/376348e59b89680203d825f9.html
      

  2.   

    http://www.codersource.net/mfc/mfc-clistctrl/working-with-ado-and-clistctrl.aspx
    资源很多
      

  3.   

        _ConnectionPtr    adoConn;
        _RecordsetPtr    m_rec;
        HRESULT hr;        _bstr_t connStr=_T("Provider=SQLOLEDB;Server=(local);Database=数据库名称; uid=sa;Password=;");    hr = adoConn.CreateInstance(__uuidof(Connection));
        hr = m_rec.CreateInstance(__uuidof(Recordset));
        hr = adoConn->Open((BSTR)connStr, L"", L"", adCmdUnspecified);
           
        hr=m_rec->Open("select * from table1", (IDispatch*)adoConn, adOpenUnspecified,
                adLockUnspecified, adCmdUnspecified);       ......//剩下的就是具体要做的事情了