http://www.csdn.net/expert/topic/491/491928.shtm
各位,帮我看看

解决方案 »

  1.   

    #include <atlbase.h>
    #import "H:\\Program Files\\Common Files\\System\\ado\\msado15.dll" no_namespace rename("EOF", "EndOfFile")void CISAMExtension::Default(CHttpServerContext* pCtxt)
    {
     //GetListFrame(pCtxt);
     char mybuf[10240];
       CoInitialize(NULL);
       try
       {
          _ConnectionPtr pConn("ADODB.Connection");
          _RecordsetPtr  pRst("ADODB.Recordset");      pConn->Open("Provider=sqloledb;Data Source=Server1;"
             "Initial Catalog=test1;User Id=sa;Password=sa;",
             "", "", adConnectUnspecified);
    // Note 1.
          pRst->Open(
             "userinfo",
             _variant_t((IDispatch *) pConn, true),
             adOpenStatic,
             adLockReadOnly,
             adCmdTable);
          pRst->MoveLast();
    // Note 2.
          sprintf(mybuf,"Last name is '%s %s'\n",
                (char*) ((_bstr_t) pRst->GetFields()->GetItem("username")->GetValue()),
                (char*) ((_bstr_t) pRst->Fields->Item["otherinfo"]->Value));      pRst->Close();
          pConn->Close();
       }
       catch (_com_error &e)
       {
          sprintf(mybuf,"Description = '%s'\n", (char*) e.Description());
       }
    ::CoUninitialize();
    *pCtxt<<mybuf;}
      

  2.   

    上面的是打开什么SQL SERVER还是ACCESS?打开ACCESS怎么写???我用ODBC的方法,为什么老出错->"在连接池生效时只允许 SQL_DRIVER_NOPROMPT "??这句话什么意思???
      

  3.   

    如果你用ADO,那么你在什么地方初始化它呢?
    AfxOleInit(); //Ado Init