如何使用BDE底层函数管理DBF库

shenxiaohu 2000-02-29 03:01:00
如何使用BDE底层函数管理DBF库,包括对库中记录做删除标记和恢复、删除已做删除标记的记录、建库。另外我如何使用C++ BUILDER建立目录。谢谢!!!
...全文
199 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
csdn2000 2000-04-01
  • 打赏
  • 举报
回复
我在Delphi用过BDE底层函数管理DBF库,方法并不太难。但比起在VFP或ACCESS中的操作可差远了,
csdn2000 2000-03-09
  • 打赏
  • 举报
回复
参考On Line Help中的Examples
tide 2000-03-03
  • 打赏
  • 举报
回复
Here is an example of a routine that I use for copying and deleting tables. It uses DB, DBTables, DbiProcs,DbiErrs, and DbiTypes. You simply provide the directory to copy from, the source table name, the directory to copy to, and the destination table name, and the BDE will copy the entire table, indexes and all to the new file. The delete function takes the path to delete from and the name of the table to delete, the BDE takes care of deleting all associated files (indexes, etc.). These procedures have been pulled off a form of mine, and I've edited them to remove some dependencies that existed with that form. They should now be completely stand-alone. (If they compile, that is! :) Use in good health, and enjoy!



--------------------------------------------------------------------------------


procedure TConvertForm.CopyTable(FromDir, SrcTblName, ToDir, DestTblName: String);
var
DBHandle: HDBIDB;
ResultCode: DBIResult;
Src, Dest, Err: Array[0..255] of Char;
SrcTbl, DestTbl: TTable;
begin
SrcTbl := TTable.Create(Application);
DestTbl := TTable.Create(Application);
try
SrcTbl.DatabaseName := FromDir;
SrcTbl.TableName := SrcTblName;
SrcTbl.Open;
DBHandle := SrcTbl.DBHandle;
SrcTbl.Close;
ResultCode := DbiCopyTable(DBHandle,false,
StrPCopy(Src,FromDir + '\' + SrcTblName),nil,
StrPCopy(Dest,ToDir + '\' + DestTblName));
if (ResultCode <> DBIERR_NONE) then
begin
DbiGetErrorString(ResultCode,Err);
raise EDatabaseError.Create('While copying ' +
FromDir + '\' + SrcTblName + ' to ' +
ToDir + '\' + DestTblName + ', the '
+ ' database engine generated the error '''
+ StrPas(Err) + '''');
end;
finally
SrcTbl.Free;
DestTbl.Free;
end;
end;

procedure TConvertForm.DeleteTable(Dir, TblName: String);
var
DBHandle: HDBIDB;
ResultCode: DBIResult;
tbl, Err: Array[0..255] of Char;
SrcTbl, DestTbl: TTable;
SrcTbl := TTable.Create(Application);
try
SrcTbl.DatabaseName := Dir;
SrcTbl.TableName := TblName;
SrcTbl.Open;
DBHandle := SrcTbl.DBHandle;
SrcTbl.Close;
ResultCode := DbiDeleteTable(DBHandle,
StrPCopy(Tbl,Dir + '\' + TblName),nil);
if (ResultCode <> DBIERR_NONE) then
begin
DbiGetErrorString(ResultCode,Err);
raise EDatabaseError.Create('While deleting ' +
Dir + '\' + TblName + ', the database ' +
'engine generated the error '''
+ StrPas(Err) + '''');
end;
finally
SrcTbl.Free;
end;
end;


--------------------------------------------------------------------------------
radish 2000-02-29
  • 打赏
  • 举报
回复
创建目录了用CreateDir

13,822

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧