关于DB数据库压缩、修复的问题!急!!!谢谢~(如果解决给1000分)(300分)

  • 主题发起人 主题发起人 topboy
  • 开始时间 开始时间
T

topboy

Unregistered / Unconfirmed
GUEST, unregistred user!
能不能给我DB数据库压缩、修复的delphi源代码。我不需要修复工具。谢谢!

最好能自动检测db库是否损坏,如果损坏就修复,最后压缩。
===============
现在急用,谢谢了!
 
检索一下会有的,别偷懒
 
控件不行吗?
http://www.delphibbs.com/delphibbs/dispq.asp?lid=122068
 
我看过有个可以修复paradox数据表的工具,带有源程序。在那个网站忘了
可以在这查一下
 
通过bde完成,研究下面代码就可以了
procedure PackTable(Table: TTable);
{ This routine copied and modified from demo unit TableEnh.pas
from Borland Int. }
var
{ FCurProp holds information about the structure of the table }
FCurProp: CurProps;
{ Specific information about the table structure, indexes, etc. }
TblDesc: CRTblDesc;
{ Uses as a handle to the database }
hDb: hDbiDB;
{ Path to the currently opened table }
TablePath: array[0..dbiMaxPathLen] of Char;
Exclusive: Boolean;
begin
if not Table.Active then _DBError(SDataSetClosed);
Check(DbiGetCursorProps(Table.Handle, FCurProp));
if StrComp(FCurProp.szTableType, szParadox) = 0 then begin
{ Call DbiDoRestructure procedure if PARADOX table }
hDb := nil;
{ Initialize the table descriptor }
FillChar(TblDesc, SizeOf(CRTblDesc), 0);
with TblDesc do begin
{ Place the table name in descriptor }
StrPCopy(szTblName, Table.TableName);
{ Place the table type in descriptor }
StrCopy(szTblType, FCurProp.szTableType);
bPack := True;
bProtected := FCurProp.bProtected;
end;
{ Get the current table's directory. This is why the table MUST be
opened until now }
Check(DbiGetDirectory(Table.DBHandle, False, TablePath));
{ Close the table }
Table.Close;
try
{ NOW: since the DbiDoRestructure call needs a valid DB handle BUT the
table cannot be opened, call DbiOpenDatabase to get a valid handle.
Setting TTable.Active = False does not give you a valid handle }
Check(DbiOpenDatabase(nil, szCFGDBSTANDARD, dbiReadWrite, dbiOpenExcl, nil,
0, nil, nil, hDb));
{ Set the table's directory to the old directory }
Check(DbiSetDirectory(hDb, TablePath));
{ Pack the PARADOX table }
Check(DbiDoRestructure(hDb, 1, @TblDesc, nil, nil, nil, False));
{ Close the temporary database handle }
Check(DbiCloseDatabase(hDb));
finally
{ Re-Open the table }
Table.Open;
end;
end
else if StrComp(FCurProp.szTableType, szDBase) = 0 then begin
{ Call DbiPackTable procedure if dBase table }
Exclusive := Table.Exclusive;
Table.Close;
try
Table.Exclusive := True;
Table.Open;
try
Check(DbiPackTable(Table.DBHandle, Table.Handle, nil, nil, True));
finally
Table.Close;
end;
finally
Table.Exclusive := Exclusive;
Table.Open;
end;
end
else DbiError(DBIERR_WRONGDRVTYPE);
end;
 
我发给你email...
 
接受答案了.
 
后退
顶部