Home > Back-end >  With ADOQuery1 do continuous use
With ADOQuery1 do continuous use

Time:09-21

I am writing a second call with ADOQuery1 do times wrong, is this why? Can't do with ADOQuery1 do used multiple times?


Procedure TForm1. FormCreate (Sender: TObject);
Var
I: integer;
The begin
With ADOQuery1 do
The begin
The Close;
SQL. The Clear;
SQL. The Add (' select distinct type from alldata ');
The Open;
end;
For I:=0 to ADOQuery1. Do RecordCount - 1
The begin
ComboBox2. Items. The Add (ADOQuery1 fieldbyname (' type '). AsString) are identical.
ADOQuery1. Next;
end;
ComboBox2. ItemIndex:=0;
end;

With ADOQuery1 do
The begin
The Close;
SQL. The Clear;
SQL. The Add (' select distinct code from alldata where type="VIP 210/0.8 E20.7" P - ');
The Open;
end;
For I:=0 to ADOQuery1. Do RecordCount - 1
The begin
ComboBox1. Items. The Add (ADOQuery1 fieldbyname (' code '). AsString) are identical.
ADOQuery1. Next;
end;
ComboBox1. ItemIndex:=0;
end;

CodePudding user response:

The 18th the end; To get rid of

CodePudding user response:

 procedure TForm1. FormCreate (Sender: TObject); 
Var I: integer;
The begin
With ADOQuery1 do
The begin
The Close;
SQL. The Clear;
SQL. The Add (' select distinct type from alldata ');
The Open;
end;
ComboBox2. Items. The clear;
While Not ADOQuery1. The DataSource. The DataSet. Eof do
The begin
ComboBox2. Items. The Add (ADOQuery1 fieldbyname (' type '). AsString) are identical.
ADOQuery1. Next;
end;
ComboBox2. ItemIndex:=0;
end;


Procedure TForm1. Button2Click (Sender: TObject);
Var I: integer;
The begin
With ADOQuery1 do
The begin
The Close;
SQL. The Clear;
SQL. The Add (' select distinct code from alldata where type="VIP 210/0.8 E20.7" P - ');
The Open;
end;
ComboBox2. Items. The clear;
ADOQuery1. The DataSource. The DataSet. First;
While Not ADOQuery1. The DataSource. The DataSet. Eof do
The begin
ComboBox1. Items. The Add (ADOQuery1 fieldbyname (' code '). AsString) are identical.
ADOQuery1. Next;
end;
ComboBox1. ItemIndex:=0;
end;

CodePudding user response:

Get rid of the close of the second

CodePudding user response:

One more Close

CodePudding user response:

 
Procedure TForm1. FormCreate (Sender: TObject);
Var
I: integer;
The begin
ComboBox1. Items. The Clear;
ComboBox2. Items. The Clear;//the two sentences with best, of course, if convinced that they are empty, without also go

With ADOQuery1 do
The begin
The Close;
{SQL. The Clear;
SQL. The Add (' select distinct type from alldata ');
This is a more concise? }
SQL. Text:='select distinct type from alldata';
The Open;
First;//First add, said from the First item
For I=1 to RecordCount do//that speed is a bit hurry
The begin
ComboBox2. Items. The Add (Trim (Fieldbyname (' type '). AsString) are identical);//add a Trim off on both sides of the space, show the more compact
Next;
end;
ComboBox2. ItemIndex:=0;

The Close;
SQL. Text:='select distinct code from alldata where type="P - 210/0.8 E20.7 VIP"';
The Open;
First;
For I:=1 to RecordCount do
The begin
ComboBox1. Items. The Add (Trim (Fieldbyname (' code '). AsString) are identical);//add a Trim off on both sides of the space, show the more compact
Next;
end;
ComboBox1. ItemIndex:=0;
end;
end;
  • Related