The execution of a function is realized, it is, a few flashes in the DBGrid, then the results, good ugly, poor effect is good;
My query is: ordinal sum each table, will output the result set into DBGrid table, and then get the value from the DBGrid saved to an Int variable,
Finally add those nine variables,
I think excuse me, how to solve the flicker?? Or is my method is wrong, isn't it can query result set implicit access to variable??????
CodePudding user response:
And in the Form of Show events this - & gt; DoubleBuffered=true;CodePudding user response:
@ songhtaoI have just joined this code, or I can't, the DBGrid queries using SQL statements can get in other places?
CodePudding user response:
My code is such (fragment) :
int a,b;
SqlCmd="SELECT sum (what zj had) FROM room_1;";
ADOQuery2 - & gt; SQL - & gt; The Clear ();//must Clear before we Add finally Open, the order cannot change
ADOQuery2 - & gt; SQL - & gt; Add (sqlCmd);
ADOQuery2 - & gt; The Open ();//can check
//ADOQuery2 - & gt; EnableControls ();
A=DBGrid1 - & gt; The Columns - & gt; The Grid - & gt; Fields [0] - & gt; The Value;
//a=DBGrid1 - & gt; ` FieldByName (" total_title ") - & gt; AsString;
//ADOQuery2 - & gt; DisableControls ();
SqlCmd="SELECT sum (what zj had) FROM room_2;";
ADOQuery2 - & gt; SQL - & gt; The Clear ();
ADOQuery2 - & gt; SQL - & gt; Add (sqlCmd);
ADOQuery2 - & gt; The Open ();//can check
//ADOQuery2 - & gt; EnableControls ();
B=DBGrid1 - & gt; The Columns - & gt; The Grid - & gt; Fields [0] - & gt; The Value;
Total=a + b;
ShowMessage (" \ t rent statistics \ n \ n "
"\ t1 floor:" + IntToStr (a) + "yuan t \ \ t \ n +"
"\ t2 floor:" + IntToStr (b) + "\ n" +
"\ t total:" + IntToStr (total) + "\ n");
My operation is not correct??
CodePudding user response:
ADOQuery2 - & gt; DisableControls ();
.//database operations
.
.
ADOQuery2 - & gt; EnableControls ();
.//interface
.
CodePudding user response:
Fyi:http://blog.163.com/tab_98/blog/static/119240972015925111011673/
CodePudding user response:
I define a variableInt the save;
And then through the SQL statements to integrate the results get DBGird table, and then save to the value read from a DBGird table in front of the save variable,
Read a table like this also like no flicker, but read several tables have this kind of circumstance happening, I think whether I operation method with problem??
CodePudding user response:
In your database, create a temporary table, every time the result of calculation, stored in the temporary table (temporary table will empty it before each use), then use DBGRID one-time read out the contents of the temporary table is ok,,,,CodePudding user response:
This data summation problem, in principle, should not be done through interface, should all data operations, summation, are finished in the database, don't mess up and interface, together,CodePudding user response:
In the form of the constructor:This - & gt; DoubleBuffered=true;
DBGrid1 - & gt; DoubleBuffered=true;
Reference:
http://blog.163.com/tab_98/blog/static/1192409720167475319874/