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 |
|
FieldList: TListBox; |
48 |
|
IBTransaction1: TIBTransaction; |
70 |
|
var |
71 |
|
IBInsertSQLEditorForm: TIBInsertSQLEditorForm; |
72 |
|
|
73 |
< |
function EditSQL(Database: TIBDatabase; SelectSQL: TStrings): boolean; |
73 |
> |
function EditSQL(DataSet: TIBCustomDataSet; SelectSQL: TStrings): boolean; |
74 |
|
|
75 |
|
implementation |
76 |
|
|
77 |
|
{$R *.lfm} |
78 |
|
|
79 |
< |
function EditSQL(Database: TIBDatabase; SelectSQL: TStrings): boolean; |
79 |
> |
function EditSQL(DataSet: TIBCustomDataSet; SelectSQL: TStrings): boolean; |
80 |
|
begin |
81 |
|
Result := false; |
82 |
|
|
83 |
< |
if assigned(Database) then |
83 |
> |
if assigned(DataSet) and assigned(DataSet.Database) then |
84 |
|
try |
85 |
< |
Database.Connected := true; |
85 |
> |
DataSet.Database.Connected := true; |
86 |
|
except on E: Exception do |
87 |
|
ShowMessage(E.Message) |
88 |
|
end; |
89 |
|
|
90 |
|
with TIBInsertSQLEditorForm.Create(Application) do |
91 |
|
try |
92 |
< |
SetDatabase(Database); |
92 |
> |
if assigned(DataSet) then |
93 |
> |
begin |
94 |
> |
SetDatabase(DataSet.Database); |
95 |
> |
GenerateParams.Checked := DataSet.GenerateParamNames; |
96 |
> |
end; |
97 |
|
SQLText.Lines.Assign(SelectSQL); |
98 |
|
Result := ShowModal = mrOK; |
99 |
|
if Result then |
100 |
< |
SelectSQL.Assign(SQLText.Lines) |
100 |
> |
begin |
101 |
> |
SelectSQL.Assign(SQLText.Lines); |
102 |
> |
if assigned(DataSet) then |
103 |
> |
DataSet.GenerateParamNames := GenerateParams.Checked |
104 |
> |
end; |
105 |
|
finally |
106 |
|
Free |
107 |
|
end; |
151 |
|
|
152 |
|
procedure TIBInsertSQLEditorForm.TestBtnClick(Sender: TObject); |
153 |
|
begin |
154 |
< |
FIBSystemTables.TestSQL(SQLText.Lines.Text) |
154 |
> |
FIBSystemTables.TestSQL(SQLText.Lines.Text,GenerateParams.Checked) |
155 |
|
end; |
156 |
|
|
157 |
|
procedure TIBInsertSQLEditorForm.TableNamesComboCloseUp(Sender: TObject); |
178 |
|
end; |
179 |
|
|
180 |
|
end. |
181 |
< |
|
181 |
> |
|