//=====================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;
}
#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;
}
解决方案 »
- 分割窗口之间的控制
- 怎么实现CTreeCtrl图标跳动,像QQ好友图标那样。
- MFC皮肤美化处理
- 关于线程退出的问题
- 大侠救命啊。。。。。。。。。。。。。。。。。
- VC++程序编译通过,运行时调试信息:Loaded 'C:\WINNT\system32\MSCTF.DLL', no matching symbolic information found.
- WSAEventSelect使用时候的困惑?100分寻求问题答案.
- 刚学MFC,请问老是出现的 Afx这个前缀是什么的缩写?
- 如何把工作线程的一些文本传给界面控件来显示出来?
- 如何把cdc类画出来的保存 成一定类型的文件 不能串行化吧
- 谁知道网络传输中的数据校检!!100分相送!!
- 怎么样不依靠菜单资源,显示一个弹出式菜单
dbaseiii+, dbaseiv, foxbase, foxpro upto and including 2.6.
dbf file structure
~~~~~~~~~~~~~~~~~~bytes description
00 foxbase+, foxpro, dbaseiii+, dbaseiv, no memo - 0x03
foxbase+, dbaseiii+ with memo - 0x83
foxpro with memo - 0xf5
dbaseiv with memo - 0x8b
dbaseiv with sql table - 0x8e01-03 last update, format yyyymmdd **correction: it is yymmdd**
04-07 number of records in file (32-bit number)
08-09 number of bytes in header (16-bit number)
10-11 number of bytes in record (16-bit number)
12-13 reserved, fill with 0x00
14 dbaseiv flag, incomplete transaction
begin transaction sets it to 0x01
end transaction or rollback reset it to 0x0015 encryption flag, encrypted 0x01 else 0x00
changing the flag does not encrypt or decrypt the records16-27 dbaseiv multi-user environment use
28 production index exists - 0x01 else 0x00
29 dbaseiv language driver id
30-31 reserved fill with 0x00
32-n field descriptor array
n+1 header record terminator - 0x0dfield descriptor array table
bytes description
0-10 field name ascii padded with 0x00
11 field type identifier (see table)
12-15 displacement of field in record
16 field length in bytes
17 field decimal places
18-19 reserved
20 dbaseiv work area id
21-30 reserved
31 field is part of production index - 0x01 else 0x00field identifier table
ascii description
c character
d date, format yyyymmdd
f floating point
g general - foxpro addition
l logical, t:t,f:f,y:y,n:n,?-not initialized
m memo (stored as 10 digits representing the dbt block number)
n numeric
p picture - foxpro additionnote all dbf field records begin with a deleted flag field.
if record is deleted - 0x2a (asterisk) else 0x20 (space)
end of file is ed with 0x1a
[email protected]