Fix detection of focused db object for usage in copy table dialog. Could happen that a trigger with the same name of the wanted table was taken, instead of the table.

This commit is contained in:
Ansgar Becker
2010-10-26 18:47:59 +00:00
parent 32c63790c3
commit 9a3211466a

View File

@@ -87,28 +87,20 @@ end;
procedure TCopyTableForm.FormShow(Sender: TObject);
var
Table, Filter: String;
Filter: String;
Dummy: String;
DBObjects: TDBObjectList;
Obj: TDBObject;
Obj: PDBObject;
Values: TStringList;
i, j: Integer;
Item: TMenuItem;
Tree: TVirtualStringTree;
begin
if Mainform.DBtree.Focused then
Table := Mainform.ActiveDbObj.Name
Tree := Mainform.DBtree
else
Table := Mainform.ListTables.Text[Mainform.ListTables.FocusedNode, 0];
DBObjects := MainForm.ActiveConnection.GetDBObjects(Mainform.ActiveDatabase);
FDBObj := nil;
for Obj in DBObjects do begin
if Obj.Name = Table then begin
FDBObj := Obj;
break;
end;
end;
if FDBObj = nil then
Exception.Create('Database object "'+Table+'" not found.');
Tree := Mainform.ListTables;
Obj := Tree.GetNodeData(Tree.FocusedNode);
FDBObj := Obj^;
editNewTablename.Text := FDBObj.Name + '_copy';
editNewTablename.SetFocus;
lblNewTablename.Caption := 'Copy ''' + FDBObj.Name + ''' to new db.table:';