6 |
|
|
7 |
|
uses |
8 |
|
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, |
9 |
< |
StdCtrls, IBSystemTables, IBDatabase; |
9 |
> |
StdCtrls, IBSystemTables, IBDatabase, IBCustomDataSet; |
10 |
|
|
11 |
|
type |
12 |
|
|
16 |
|
Button1: TButton; |
17 |
|
Button2: TButton; |
18 |
|
GenerateBtn: TButton; |
19 |
+ |
GenerateParams: TCheckBox; |
20 |
|
TestBtn: TButton; |
21 |
|
FieldList: TListBox; |
22 |
|
IBTransaction1: TIBTransaction; |
47 |
|
var |
48 |
|
IBRefreshSQLEditorForm: TIBRefreshSQLEditorForm; |
49 |
|
|
50 |
< |
function EditSQL(Database: TIBDatabase; SelectSQL: TStrings): boolean; |
50 |
> |
function EditSQL(DataSet: TIBCustomDataSet; SelectSQL: TStrings): boolean; |
51 |
|
|
52 |
|
implementation |
53 |
|
|
54 |
|
{$R *.lfm} |
55 |
|
|
56 |
< |
function EditSQL(Database: TIBDatabase; SelectSQL: TStrings): boolean; |
56 |
> |
function EditSQL(DataSet: TIBCustomDataSet; SelectSQL: TStrings): boolean; |
57 |
|
begin |
58 |
|
Result := false; |
59 |
< |
if assigned(Database) then |
59 |
> |
if assigned(DataSet) and assigned(DataSet.Database) then |
60 |
|
try |
61 |
< |
Database.Connected := true; |
61 |
> |
DataSet.Database.Connected := true; |
62 |
|
except on E: Exception do |
63 |
|
ShowMessage(E.Message) |
64 |
|
end; |
65 |
|
|
66 |
|
with TIBRefreshSQLEditorForm.Create(Application) do |
67 |
|
try |
68 |
< |
SetDatabase(Database); |
68 |
> |
if assigned(DataSet) then |
69 |
> |
begin |
70 |
> |
SetDatabase(DataSet.Database); |
71 |
> |
GenerateParams.Checked := DataSet.GenerateParamNames; |
72 |
> |
end; |
73 |
|
SQLText.Lines.Assign(SelectSQL); |
74 |
|
Result := ShowModal = mrOK; |
75 |
|
if Result then |
76 |
< |
SelectSQL.Assign(SQLText.Lines) |
76 |
> |
begin |
77 |
> |
SelectSQL.Assign(SQLText.Lines); |
78 |
> |
if assigned(DataSet) then |
79 |
> |
DataSet.GenerateParamNames := GenerateParams.Checked |
80 |
> |
end; |
81 |
|
finally |
82 |
|
Free |
83 |
|
end; |
130 |
|
|
131 |
|
procedure TIBRefreshSQLEditorForm.TestBtnClick(Sender: TObject); |
132 |
|
begin |
133 |
< |
FIBSystemTables.TestSQL(SQLText.Lines.Text) |
133 |
> |
FIBSystemTables.TestSQL(SQLText.Lines.Text,GenerateParams.Checked) |
134 |
|
end; |
135 |
|
|
136 |
|
procedure TIBRefreshSQLEditorForm.TableNamesComboCloseUp(Sender: TObject); |
158 |
|
end; |
159 |
|
|
160 |
|
end. |
152 |
– |
|