Home > Back-end >  About dbchart1 execute two adoquery1 statement in DLEPHI7 error, to a certain field to find?
About dbchart1 execute two adoquery1 statement in DLEPHI7 error, to a certain field to find?

Time:10-12

Himself in writing a program, use DBchart controls, there are two radio buttons, according to the first execution of a query, according to the second perform another query, field is different, when performed separately, which are determined, but the reason to perform a first, and then perform another radio button, it will be prompted to perform the query results field, N the lookup days not bitter, warrior, please save!!!!! Here is the source code:

If radiobutton1. Checked=true then
The begin
Sqlstring:='select xm, ZJHM CSRQ, GJDQDM, count (xm) as CRCS from BJ_YW_T_CRJRYDK Where (CRRQ between' ' '+ the start_date +' ' ' '+' and '+' ' ' ' '+ end_date +') '+' GROUP BY xm, ZJHM CSRQ, GJDQDM HAVING count (xm) '+ CXTJ + cxtextedit1. Text +' order BY CRCS desc ';
//showmessage (sqlstring);
Dbgrid1. Columns [0]. Title. Caption:='name';
Dbgrid1. Columns [0]. Width:=300;
Dbgrid1. Columns [0]. FieldName:='xm';
Dbgrid1. Columns [1]. Title. Caption:='id number;
Dbgrid1. Columns [1]. Width:=186;
Dbgrid1. Columns [1]. FieldName:='ZJHM';
Dbgrid1. Columns [2]. Title. Caption:='date of birth;
Dbgrid1. Columns [2]. Width:=100;
Dbgrid1. Columns [2]. FieldName:='CSRQ';
Dbgrid1. Columns [3]. Title. Caption:='country code;
Dbgrid1. Columns [3]. Width:=100;
Dbgrid1. Columns [3]. FieldName:='GJDQDM';
Dbgrid1. Columns [4]. Title. Caption:='access number;
Dbgrid1. Columns [4]. Width:=100;
Dbgrid1. Columns [4]. FieldName:='CRCS';

With adoquery1 do
The begin
The Close;
SQL. The Clear;
SQL. The Add (sqlstring);
The Open;
end;
If adoquery1. RecordCount & gt; 0 then
The begin
Num=inttostr (adoquery1. RecordCount);
Statusbar1. Panels [1]. The Text:=num;
Bitbtn3. Enabled:=true;
Bitbtn6. Enabled:=true;
Bitbtn1. Enabled:=false;
Dbgrid1. Columns [0]. The font. Color:=clRed;
Dbgrid1. Columns [1]. The font. Color:=clWindowText;
Dbgrid1. Columns [2]. The font. Color:=clWindowText;
DBChart1. Title. The Text [0] :='entry-exit personnel transit frequency statistics sketch;
With DBChart1 do
The begin
With Series1 do
The begin
//Series1. The Clear;
//series1. Active:=false;
Adoquery1. Active:=True;
DataSource:=adoquery1;
Xm XLabelsSource:=' ';
YValues. ValueSource:='CRCS';
//series1. Active:=true;
end;
end;
End
The else
The begin
Statusbar1. Panels [1]. The Text:='0';
Application. MessageBox (' there is no data! ', 'prompt', 64);
end;
End
Else if radiobutton2. Checked=true then
The begin
Sqlstring:='select hc, JWGJBS JNGJBS, GJDQDM, count (hc) as CRCS from BJ_YW_T_CRJJTGJDK Where (CRRQ between' ' '+ the start_date +' ' ' '+' and '+' ' ' '+ end_date +') '+' GROUP BY hc, JWGJBS JNGJBS, GJDQDM HAVING count (hc) '+ CXTJ + cxtextedit1. Text +' order BY CRCS desc ';
Dbgrid1. Columns [0]. Title. Caption:='vehicle brands';
Dbgrid1. Columns [0]. Width:=200;
Dbgrid1. Columns [0]. FieldName:='hc';
Dbgrid1. Columns [1]. Title. Caption:='overseas identity;
Dbgrid1. Columns [1]. Width:=150;
Dbgrid1. Columns [1]. FieldName:='JWGJBS';
Dbgrid1. Columns [2]. Title. Caption:='identity in';
Dbgrid1. Columns [2]. Width:=150;
Dbgrid1. Columns [2]. FieldName:='JNGJBS';
Dbgrid1. Columns [3]. Title. Caption:='countries';
Dbgrid1. Columns [3]. Width:=100;
Dbgrid1. Columns [3]. FieldName:='GJDQDM';
Dbgrid1. Columns [4]. Title. Caption:='access number;
Dbgrid1. Columns [4]. Width:=100;
Dbgrid1. Columns [4]. FieldName:='CRCS';
With adoquery1 do
The begin
The close;
SQL. The Clear;
SQL. The Add (sqlstring);
//showmessage (sqlstring);
The Open;
end;
If adoquery1. RecordCount & gt; 0 then
The begin
Num=inttostr (adoquery1. RecordCount);
Statusbar1. Panels [1]. The Text:=num;
Bitbtn3. Enabled:=true;
Bitbtn6. Enabled:=true;
Bitbtn1. Enabled:=false;
Dbgrid1. Columns [0]. The font. Color:=clRed;
Dbgrid1. Columns [1]. The font. Color:=clWindowText;
Dbgrid1. Columns [2]. The font. Color:=clWindowText;
DBChart1. Title. The Text [0] :='entry-exit vehicles crossing number statistics sketch;
With DBChart1 do
The begin
With Series1 do
The begin
//series1. The Clear;
//series1. Active:=false;
Adoquery1. Active:=True;
DataSource:=adoquery1;
XLabelsSource:='hc';
YValues. ValueSource:='CRCS';
//series1. Active:=true;
end;
end;
End
The else
The begin
Statusbar1. Panels [1]. The Text:='0';
Application. MessageBox (' there is no data! ', 'prompt', 64);
end;
end;
end;

CodePudding user response:

Line before the query execution dbgrid1. Columns. The Clear

CodePudding user response:

Reverzeng, tried it on, no, wrong: prompt dbgrid1 column value can not find, please think again, what good? Thank you very much!!!!!!

CodePudding user response:


CodePudding user response:

I still think is similar problems, set breakpoints check to see where I went wrong, should be error in the open.

CodePudding user response:

Description, you can make myself clear, after is pressed a button, press another button immediately, so is because a adoquery haven't performed, you asked for another SQL queries, cause problems, of course, this should be the data source index is not good enough, or data recording is too big, lead to adoquery query time is longer, optional best have a variable to record the state of the query
  • Related