其他的驱动可以吗?试了好象不行。

解决方案 »

  1.   

    //=====================Open dbf database file
    #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\\images.dbf database file!\n");
       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();
    return 0;
    }
      

  2.   

    遥想数年前(至少是求伯军、吴晓军时代),很多人都会解释dbf文件头,直接处理dbf文件,而且当成看家本事。我的程序早就丢了,不然我早给你了。不过,告诉你一个事实,dbf文件如果不考虑Memo字段,每个记录在文件里是定长的。你用二进制编辑器打开文件看,dbf中的数据都是用明码字符串表示的,数据用空格分开,非常容易解读。只要你找到第一笔记录的偏移量、第二笔记录的偏移量就好办了。注意被删除的记录在记录开头有一个"*"号。不过用ODBC ADO可能更绅士些!