32 |
|
|
33 |
|
uses |
34 |
|
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, |
35 |
< |
StdCtrls, ComCtrls, IBSystemTables, IBDatabase; |
35 |
> |
StdCtrls, ComCtrls, IBSystemTables, IBDatabase, IBCustomDataSet, IB; |
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 |
– |
uses IBSQL; |
94 |
– |
|
92 |
|
{$R *.lfm} |
93 |
|
|
94 |
< |
function EditSQL(Database: TIBDatabase; SelectSQL: TStrings): boolean; |
94 |
> |
function EditSQL(DataSet: TIBCustomDataSet; SelectSQL: TStrings): boolean; |
95 |
|
begin |
96 |
|
Result := false; |
97 |
< |
if assigned(Database) then |
97 |
> |
if assigned(DataSet) and assigned(DataSet.Database) then |
98 |
|
try |
99 |
< |
Database.Connected := true; |
99 |
> |
DataSet.Database.Connected := true; |
100 |
|
except on E: Exception do |
101 |
|
ShowMessage(E.Message) |
102 |
|
end; |
103 |
|
|
104 |
|
with TIBSelectSQLEditorForm.Create(Application) do |
105 |
|
try |
106 |
< |
SetDatabase(Database); |
106 |
> |
if assigned(DataSet) then |
107 |
> |
begin |
108 |
> |
SetDatabase(DataSet.Database); |
109 |
> |
GenerateParams.Checked := DataSet.GenerateParamNames; |
110 |
> |
end; |
111 |
|
SQLText.Lines.Assign(SelectSQL); |
112 |
|
Result := ShowModal = mrOK; |
113 |
|
if Result then |
114 |
< |
SelectSQL.Assign(SQLText.Lines) |
114 |
> |
begin |
115 |
> |
SelectSQL.Assign(SQLText.Lines); |
116 |
> |
if assigned(DataSet) then |
117 |
> |
DataSet.GenerateParamNames := GenerateParams.Checked |
118 |
> |
end; |
119 |
|
finally |
120 |
|
Free |
121 |
|
end; |
197 |
|
|
198 |
|
procedure TIBSelectSQLEditorForm.TestBtnClick(Sender: TObject); |
199 |
|
begin |
200 |
< |
FIBSystemTables.TestSQL(SQLText.Lines.Text) |
200 |
> |
FIBSystemTables.TestSQL(SQLText.Lines.Text,GenerateParams.Checked) |
201 |
|
end; |
202 |
|
|
203 |
|
procedure TIBSelectSQLEditorForm.ExecutePageShow(Sender: TObject); |
244 |
|
end; |
245 |
|
|
246 |
|
end. |
242 |
– |
|