建议你先去看一本书
“teach youself database programming with visual c++ in 21 days"
那本书将的很详细

解决方案 »

  1.   

    谢谢,我手头上一本MFC Visual C++ 6 编程技术内幕
    就象一个查询手册,一点都帮不上忙
      

  2.   

    很短的程序,应该好看了吧
    #include "stdafx.h"
    #import "c:\\Program Files\\Common Files\\System\\ado\\msado15.dll" no_namespace rename("EOF", "EndOfFile")
    int main(int argc, char* argv[])
    {
    printf("Use ADO to open C:\\tmp\\test.mdb database file!\n");
       CoInitialize(NULL);
       try
       {
          _ConnectionPtr pConn("ADODB.Connection");
          _RecordsetPtr  pRst("ADODB.Recordset");
           pConn->Open("PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:\\tmp\\test.mdb;UID=;PWD=aaa;" //pConn->Open("Provider= Microsoft.Jet.OLEDB.4.0;Data Source=C:\\tmp\\test.mdb;"//this is also OK
    ,"","",adConnectUnspecified);
    //Open "users" table
          pRst->Open("users", _variant_t((IDispatch *) pConn, true),
             adOpenStatic, adLockReadOnly, adCmdTable);
      FieldsPtr fds=pRst->GetFields();
      printf("printf field name of the table\n");
      for(int i=0;i<fds->GetCount();i++)
      {
      FieldPtr fd=fds->GetItem(_variant_t(short(i)));
      printf("%s   ",(LPCTSTR)fd->GetName());
      }
      printf("\n");
          pRst->Close();
          pConn->Close();
       }
       catch (_com_error &e)
       {
          printf("Description = '%s'\n", (char*) e.Description());
       }
    ::CoUninitialize();
    return 0;
    }
      

  3.   

    to masterz()
    很好,谢谢
    能否帮我解释一下下面几点FieldsPtr fds=pRst->GetFields();FieldPtr fd=fds->GetItem(_variant_t(short(i)));
    printf("%s  ",(LPCTSTR)fd->GetName());
          
      

  4.   

    FieldsPtr fds=pRst->GetFields();//得到field集合
    FieldPtr fd=fds->GetItem(_variant_t(short(i)));//得到第(i)个字段
    printf("%s  ",(LPCTSTR)fd->GetName());//得到字段的名字
      

  5.   

    去www.vchelp.net查找“数据库“,里面有很详细的ADO中文教程