VC中对*.dbf自由表文件操作,只能用VFP或FOXPRO的ODBC驱动吗? 其他的驱动可以吗?试了好象不行。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //=====================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;} 遥想数年前(至少是求伯军、吴晓军时代),很多人都会解释dbf文件头,直接处理dbf文件,而且当成看家本事。我的程序早就丢了,不然我早给你了。不过,告诉你一个事实,dbf文件如果不考虑Memo字段,每个记录在文件里是定长的。你用二进制编辑器打开文件看,dbf中的数据都是用明码字符串表示的,数据用空格分开,非常容易解读。只要你找到第一笔记录的偏移量、第二笔记录的偏移量就好办了。注意被删除的记录在记录开头有一个"*"号。不过用ODBC ADO可能更绅士些! OTL调用 ORACLE问题 长了见识,散分 局域网内 组播传送图片数据 哪个是比较权威的关于硬件报价的网站。关于笔记本报价的权威网站。 散发!!今天过生日还要上班!郁闷,还好有MM在家做饭等我,Happy :-) 请大虾帮忙解决这个问题!马上结贴。再次送上100分 请问那里可以下载MSDN2003? 有关UDP的简单的问题 怎样才能将文件路径转变过来?我已能取出文件路径 listview的问题 开发版本控制软件 软件发布的谜题,提供线索者有分。急
#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;
}