32 |
|
|
33 |
|
uses |
34 |
|
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, |
35 |
< |
StdCtrls, ComCtrls, IBSystemTables, IBDatabase; |
35 |
> |
StdCtrls, ComCtrls, IBSystemTables, IBDatabase, IBCustomDataSet; |
36 |
|
|
37 |
|
type |
38 |
|
|
42 |
|
Button1: TButton; |
43 |
|
Button2: TButton; |
44 |
|
GenerateBtn: TButton; |
45 |
+ |
GenerateParams: TCheckBox; |
46 |
|
SelectProcedure: TLabel; |
47 |
|
TestBtn: TButton; |
48 |
|
FieldList: TListBox; |
84 |
|
procedure SetDatabase(Database: TIBDatabase); |
85 |
|
end; |
86 |
|
|
86 |
– |
var |
87 |
– |
IBSelectSQLEditorForm: TIBSelectSQLEditorForm; |
87 |
|
|
88 |
< |
function EditSQL(Database: TIBDatabase; SelectSQL: TStrings): boolean; |
88 |
> |
function EditSQL(DataSet: TIBCustomDataSet; SelectSQL: TStrings): boolean; |
89 |
|
|
90 |
|
implementation |
91 |
|
|
93 |
|
|
94 |
|
{$R *.lfm} |
95 |
|
|
96 |
< |
function EditSQL(Database: TIBDatabase; SelectSQL: TStrings): boolean; |
96 |
> |
function EditSQL(DataSet: TIBCustomDataSet; SelectSQL: TStrings): boolean; |
97 |
|
begin |
98 |
|
Result := false; |
99 |
< |
if assigned(Database) then |
99 |
> |
if assigned(DataSet) and assigned(DataSet.Database) then |
100 |
|
try |
101 |
< |
Database.Connected := true; |
101 |
> |
DataSet.Database.Connected := true; |
102 |
|
except on E: Exception do |
103 |
|
ShowMessage(E.Message) |
104 |
|
end; |
105 |
|
|
106 |
|
with TIBSelectSQLEditorForm.Create(Application) do |
107 |
|
try |
108 |
< |
SetDatabase(Database); |
108 |
> |
if assigned(DataSet) then |
109 |
> |
begin |
110 |
> |
SetDatabase(DataSet.Database); |
111 |
> |
GenerateParams.Checked := DataSet.GenerateParamNames; |
112 |
> |
end; |
113 |
|
SQLText.Lines.Assign(SelectSQL); |
114 |
|
Result := ShowModal = mrOK; |
115 |
|
if Result then |
116 |
< |
SelectSQL.Assign(SQLText.Lines) |
116 |
> |
begin |
117 |
> |
SelectSQL.Assign(SQLText.Lines); |
118 |
> |
if assigned(DataSet) then |
119 |
> |
DataSet.GenerateParamNames := GenerateParams.Checked |
120 |
> |
end; |
121 |
|
finally |
122 |
|
Free |
123 |
|
end; |
199 |
|
|
200 |
|
procedure TIBSelectSQLEditorForm.TestBtnClick(Sender: TObject); |
201 |
|
begin |
202 |
< |
FIBSystemTables.TestSQL(SQLText.Lines.Text) |
202 |
> |
FIBSystemTables.TestSQL(SQLText.Lines.Text,GenerateParams.Checked) |
203 |
|
end; |
204 |
|
|
205 |
|
procedure TIBSelectSQLEditorForm.ExecutePageShow(Sender: TObject); |
246 |
|
end; |
247 |
|
|
248 |
|
end. |
249 |
< |
|
249 |
> |
|