Home > Back-end >  In different forms of Delphi call adoquery of dm, different forms to execute SQL code
In different forms of Delphi call adoquery of dm, different forms to execute SQL code

Time:09-28

Each great spirit:
In different forms of Delphi call adoquery of dm, different forms to perform different SQL code how?

When I was in a closed form, will adoquery. SQL. The clear also useless, it's no use is not active,

When open the display of data or another form of the original form of adoquery SQL code as a result, ask you a great god how should solve?

CodePudding user response:

 
{dm unit:}
With adoquery1 do
The begin
The close;
SQL. Text:='select * from table'; {different function, to use a different SQL statements}
The open;
The end;

CodePudding user response:

Do not understand, that I how to call in the form? After the execution is primarily a form data don't know how to release, then the next form when the show is about to go wrong,

CodePudding user response:

A form of a query, don't share!!!!!!

CodePudding user response:

Dm can build two procedure calls, such as:
Public
Procedure TS1.
The begin
With adoquery1 do
The begin
The close;
SQL. Text:='select * from table1';
The open;
The end;
The end;
Procedure TS2.
The begin
With adoquery2 do
The begin
The close;
SQL. Text:='select * from table2';
The open;
The end;
The end;

Forms 1 call TS1, form 2 call TS2,
Form show: establish directly form together with the main form of start, closing did not release resources,
Form showmodal: dynamic established forms, closing release resources,

CodePudding user response:

The
reference 3 floor linuxpingwangping response:
a form a query, do not share!!!!


It always feels good start slow, I was a form of a query, the back into a query, feel much faster,

CodePudding user response:

reference 4 floor yct0605 response:
dm can be established in two procedure calls, such as:
Public
Procedure TS1.
The begin
With adoquery1 do
The begin
The close;
SQL. Text:='select * from table1';
The open;
The end;
The end;
Procedure TS2.
The begin
With adoquery2 do
The begin
The close;
SQL. Text:='select * from table2';
The open;
The end;
The end;

Forms 1 call TS1, form 2 call TS2,
Form show: establish directly form together with the main form of start, closing did not release resources,
Form showmodal: dynamic established forms, closing release resources,


It's just two forms, I nearly 20 forms to call ah, can not too much trouble,

CodePudding user response:

refer to 6th floor MFKPFG response:
Quote: refer to 4th floor yct0605 response:

Dm can build two procedure calls, such as:
Public
Procedure TS1.
The begin
With adoquery1 do
The begin
The close;
SQL. Text:='select * from table1';
The open;
The end;
The end;
Procedure TS2.
The begin
With adoquery2 do
The begin
The close;
SQL. Text:='select * from table2';
The open;
The end;
The end;

Forms 1 call TS1, form 2 call TS2,
Form show: establish directly form together with the main form of start, closing did not release resources,
Form showmodal: dynamic established forms, closing release resources,


It's just two forms, I nearly 20 forms to call ah, can not too much trouble,

That should see you form the show or showmodal, recommended showmodal, such a adoquery solved, if show, when more than 20 forms in software start loading executable files not only big but also very slow start,

CodePudding user response:

Look at the DPR file, set to start form the main form a!!!!!

All query active by default set to false, need to open again!

CodePudding user response:

1, define a public ADO connection unit;
2, the other Form unit to join USES the unit;
3, in the Form used in the DBGrid associated with the DataSource
4, the use of database SQL statements, speaking, reading and writing,

CodePudding user response:

A form a adoquery, form is not generated by default, when need to regenerate, adoquery don't open the default, need to open again,
In this way, a window opens, most would be in 2 to 3 seconds,

CodePudding user response:

If there are data-bound controls in the form, or a form a adoquery is good, but remember, must be adoquery form closed. The close, this is a good habit, not slow, if it is used to execute the command, can share, the process of writing a public good

CodePudding user response:

To establish a common unit file, in the form reference line,
Remember when main form to establish initialized.

USES the
MyQuerys;

.

The begin
MyQuery1. Close;
MyQuery1. SQL. Text:=sSQLText;
MyQuery1. Open;
AControl. The DataSet:=myQuery1;
.
The end;

CodePudding user response:

To Close

CodePudding user response:

With the dm. Qry1 do begin
The close;
SQL. The clear;
SQL. Add (");//SQL you need
The open;
The end;
  • Related