32 |
|
|
33 |
|
uses |
34 |
|
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, |
35 |
< |
StdCtrls, IBSystemTables, IBDatabase; |
35 |
> |
StdCtrls, IBSystemTables, IBDatabase, IBCustomDataSet; |
36 |
|
|
37 |
|
type |
38 |
|
|
42 |
|
Button1: TButton; |
43 |
|
Button2: TButton; |
44 |
|
GenerateBtn: TButton; |
45 |
+ |
GenerateParams: TCheckBox; |
46 |
|
TestBtn: TButton; |
47 |
|
IBTransaction1: TIBTransaction; |
48 |
|
IncludePrimaryKeys: TCheckBox; |
74 |
|
var |
75 |
|
IBModifySQLEditorForm: TIBModifySQLEditorForm; |
76 |
|
|
77 |
< |
function EditSQL(Database: TIBDatabase; SelectSQL: TStrings): boolean; |
77 |
> |
function EditSQL(DataSet: TIBCustomDataSet; SelectSQL: TStrings): boolean; |
78 |
|
|
79 |
|
implementation |
80 |
|
|
81 |
|
{$R *.lfm} |
82 |
|
|
83 |
< |
function EditSQL(Database: TIBDatabase; SelectSQL: TStrings): boolean; |
83 |
> |
function EditSQL(DataSet: TIBCustomDataSet; SelectSQL: TStrings): boolean; |
84 |
|
begin |
85 |
|
Result := false; |
86 |
< |
if assigned(Database) then |
86 |
> |
if assigned(DataSet) and assigned(DataSet.Database) then |
87 |
|
try |
88 |
< |
Database.Connected := true; |
88 |
> |
DataSet.Database.Connected := true; |
89 |
|
except on E: Exception do |
90 |
|
ShowMessage(E.Message) |
91 |
|
end; |
92 |
|
|
93 |
|
with TIBModifySQLEditorForm.Create(Application) do |
94 |
|
try |
95 |
< |
SetDatabase(Database); |
95 |
> |
if assigned(DataSet) then |
96 |
> |
begin |
97 |
> |
SetDatabase(DataSet.Database); |
98 |
> |
GenerateParams.Checked := DataSet.GenerateParamNames; |
99 |
> |
end; |
100 |
|
SQLText.Lines.Assign(SelectSQL); |
101 |
|
Result := ShowModal = mrOK; |
102 |
|
if Result then |
103 |
< |
SelectSQL.Assign(SQLText.Lines) |
103 |
> |
begin |
104 |
> |
SelectSQL.Assign(SQLText.Lines); |
105 |
> |
if assigned(DataSet) then |
106 |
> |
DataSet.GenerateParamNames := GenerateParams.Checked |
107 |
> |
end; |
108 |
|
finally |
109 |
|
Free |
110 |
|
end; |
160 |
|
|
161 |
|
procedure TIBModifySQLEditorForm.TestBtnClick(Sender: TObject); |
162 |
|
begin |
163 |
< |
FIBSystemTables.TestSQL(SQLText.Lines.Text) |
163 |
> |
FIBSystemTables.TestSQL(SQLText.Lines.Text,GenerateParams.Checked) |
164 |
|
end; |
165 |
|
|
166 |
|
procedure TIBModifySQLEditorForm.TableNamesComboCloseUp(Sender: TObject); |
188 |
|
end; |
189 |
|
|
190 |
|
end. |
191 |
< |
|
191 |
> |
|