📄 如何pack table (2001年1月19日).txt
字号:
如何PACK TABLE (2001年1月19日)
本站更新 分类: 作者:赵亦平 推荐: 阅读次数:454
(http://www.codesky.net)
--------------------------------------------------------------------------------
如何PACK TABLE
Pack一个dBASE 数据库需要调用BDE函数DbiPackTable。下面我将会用一个例子来说明如何使用这个函数,包括错误检测。要使用DbiPackTable函数,调用的单元必须在Uses部分包含DbiTypes,DbiErrs,DbiProcs。如果函数失败,它不会产生一个错误消息,所以为了判断是成功还是失败,你必须自己检查函数的返回值,如果函数成功,它返回DBIERR--NONE,否则返回预定的值,通过这个返回值,我们可以知道错误的原因并且如何去解决它。下面是一个例子:
procedure TForm1.Button1Click(Sender: TObject);
var
Error: DbiResult;
ErrorMsg: String;
Special: DBIMSG;
begin
table1.Active := False;
try
Table1.Exclusive := True;
Table1.Active := True;
Error := DbiPackTable(Table1.DBHandle, Table1.Handle, nil, szdBASE, True);
Table1.Active := False;
Table1.Exclusive := False;
finally
Table1.Active := True;
end;
case Error of
DBIERR_NONE:
ErrorMsg := 'Successful';
DBIERR_INVALIDPARAM:
ErrorMsg := 'The specified table name or the pointer to the table name is NULL';
DBIERR_INVALIDHNDL:
ErrorMsg := 'The specified database handle or cursor handle is invalid or NULL';
DBIERR_NOSUCHTABLE:
ErrorMsg := 'Table name does not exist';
DBIERR_UNKNOWNTBLTYPE:
ErrorMsg := 'Table type is unknown';
DBIERR_NEEDEXCLACCESS:
ErrorMsg := 'The table is not open in exclusive mode';
else
DbiGetErrorString(Error, Special);
ErrorMsg := '[' + IntToStr(Error) + ']: ' + Special;
end;
MessageDlg(ErrorMsg, mtWarning, [mbOk], 0);
end;
赵亦平
1999.9.5
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -