用RecordSet读到数据后,如何通过Filed的Index来访问数据?

解决方案 »

  1.   

    怎么没有找到?我用的是_RecordsetPtr
      

  2.   

    _variant_t vCount = _pRecordset->GetCollect(vIndex);///取得第一个字段的值放入vCount变量
      

  3.   

    tye like this:
     CoInitialize(NULL);
       try
       {
          _ConnectionPtr pConn("ADODB.Connection");
          _RecordsetPtr  pRst("ADODB.Recordset");
    pConn->Open("Driver={Microsoft dBASE Driver (*.dbf)};DBQ=C:\\tmp\\; DriverID=533;"
    ,"","",adConnectUnspecified);
          pRst->Open("images", _variant_t((IDispatch *) pConn, true),
             adOpenStatic, adLockReadOnly, adCmdTable);
      FieldsPtr fds=pRst->GetFields();
      printf("printf field name of all 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();
      

  4.   

    to kingzai() 呵呵,贴了两遍