我的方法是copy所有文件进行备份。copy前断掉数据库连接:table.close....
Dbsession.close;copy后再打开连接:dbsession.open,table.open,可一执行到table.open就报错"Share violation. table.db",哪位知道为什么?
Dbsession.close;copy后再打开连接:dbsession.open,table.open,可一执行到table.open就报错"Share violation. table.db",哪位知道为什么?
解决方案 »
- 江湖救急!鼠标点中excel表其中的一个单元,自动出现个对话框,然后进行相关操作,如何实现!!!
- 如何在delphi 中调用fastreport 3.20 制作的报表呀?
- DELPHI7启动时总是自动创建一个工程,请问如何关掉?
- 我做的DLL,不能动态调用?请帮忙看看.
- 为什么DBGridEh的列复选框不能编辑?
- 我这个语句错在那儿?TreeView1.Items.Add(TreeView1.Selected,'长城公司');
- 求在Memo控件中打开(OpenDialog)保存(SaveDialog)文本文件源码,用来学习。
- 求解最简化SQL语句的写法:
- 如何使用interbase?
- 21分的问题,再寻支持 delphi6的条码控件。
- Project Peoject1.exe raised exception class EvatiantError with message'Invalid variant type conversion'.Process stopped.
- 如何得到winapi的帮助,和dll的函数
procedure TMainForm.CreateStructure(const FName: String);
var
sOldPath: String;
OldCursor: word;
tbsLt: TStringList;
DupI,Dupj: Integer;
fldLt:TStringList;
procedure GetFldTbs(fldLt:pointer;folderName:string);
type
pFldLt=^TStringList;
var
vsFldLt:pFldLt;
tbFldLt:TStringList;
searchRec : TSearchRec;
findResult :integer;
dbPath :string;
begin
vsFldLt :=pFldLt(fldLt);
tbFldLt :=vsFldLt^;
if folderName[length(folderName)]<>'\' then folderName :=folderName+'\';
findResult :=findFirst(folderName+'*.db',faAnyFile,searchRec);
try
while findResult =0 do
begin
tbFldLt.Add(searchRec.name);
findResult :=findNext(searchRec);
end;
finally
FindClose(searchRec);
end;
end;
procedure sumTabsLt(tbsLt :pointer;fldLt:TStringList);
type
PTSLt=^TStringList;
var
vsPTLt :PTSLt;
ReFoldTbsLt :TStringList;
i,j :integer;
begin
vsPTLt :=PTSLt(tbsLt);
ReFoldTbsLt :=TStringList.create;
ReFoldTbsLt :=vsPTLt^;
for i:=0 to fldLt.count -1 do
for j:=0 to ReFoldTbsLt.count -1 do
if UpperCase(Trim(ReFoldTbsLt.Strings[j]+'.db'))=UpperCase(Trim(fldLt.Strings[i])) then
begin
ReFoldTbsLt.Delete(j);
break;
end
end;
{add end}
procedure DupEmptyTable(const FName: string; FromDb, ToDb: TDatabase);
var
Dst: TTable;
Src: TTable;
i: Integer;
Ok: Boolean;
sIndexName: string;
sIndexOptions: TIndexOptions;
begin
Src := TTable.Create(nil);
Dst := TTable.Create(nil);
try
with Src do
begin
DatabaseName := FromDb.DatabaseName;
TableName := FName;
IndexDefs.Update;
end; with Dst do
begin
DatabaseName := ToDb.DatabaseName;
TableName := FName;
FieldDefs.Assign(Src.FieldDefs);
IndexDefs.Clear;
CreateTable;
for i := 0 to Src.IndexDefs.Count - 1 do
with Src.IndexDefs[i] do
begin
sIndexName := Name;
sIndexOptions := Options;
repeat
Ok := True;
try
AddIndex(sIndexName, Fields, sIndexOptions);
except
Ok := False;
if ixPrimary in sIndexOptions then
sIndexOptions := sIndexOptions - [ixPrimary]
else if ixExpression in sIndexOptions then
sIndexOptions := sIndexOptions - [ixExpression]
else if ixCaseInsensitive in sIndexOptions then
sIndexOptions := sIndexOptions - [ixCaseInsensitive]
else if ixUnique in sIndexOptions then
sIndexOptions := sIndexOptions - [ixUnique]
else if ixDescending in sIndexOptions then
sIndexOptions := sIndexOptions - [ixDescending]
else Ok := True; {no more retry}
if (sIndexName = '') and not (ixPrimary in sIndexOptions) then
sIndexName := UpperCase(TableName) + '_PRIMARY';
end;
until Ok;
end;
end;
finally
Src.Free;
Dst.Free;
end;
end;
begin
try
OldCursor := Screen.Cursor;
Screen.Cursor := crHourglass;
sOldPath := DbFolder.Params.Values['PATH'];
ToggleDatabase(FName, DbFolder);
fldLt :=TStringList.create;
tbsLt :=TStringList.Create; GetFldTbs(@fldLt,FName);
SrverGetTbsLt(@tbsLt);
sumTabsLt(@tbsLt,fldLt); Dupj :=tbsLt.Count;
if Dupj > 1 then begin
for Dupi :=0 to Dupj -1 do begin
DupEmptyTable(tbsLt.Strings[Dupi], DbMain, DbFolder);
end;
end;
finally
ToggleDatabase(sOldPath, DbFolder);
Screen.Cursor := OldCursor;
end;
end;
if not DirectoryExists(sCurDir+ sNewFolder) then
begin
ForceDirectories(sCurDir+ sNewFolder);
CreateStructure(sCurDir+ sNewFolder);
end;