Home > Back-end >  C builder operation error
C builder operation error

Time:10-03

Void __fastcall TForm1: : FormCreate (TObject * Sender)
{
ADOQuery1 - & gt; The Connection=ADOConnection1;
ADOQuery1 - & gt; Close ();
ADOQuery1 - & gt; SQL - & gt; The Clear ();
ADOQuery1 - & gt; SQL - & gt; Add (" select distinct state from the authors ");
ADOQuery1 - & gt; The Open ();

while(! ADOQuery1 - & gt; Eof) {
TreeView1 - & gt; The Items - & gt; Add (NULL, ADOQuery1 - & gt; FieldByName (" state ") - & gt; AsString) are identical.
ADOQuery1 - & gt; MoveBy (1);
}

Int n=TreeView1 - & gt; The Items - & gt; Count;
TTreeNode * node [50];
for(int i=0; iThe node [I]=TreeView1 - & gt; The Items - & gt; The Item [I];
}
for(int i=0; iADOQuery1 - & gt; Close ();
ADOQuery1 - & gt; SQL - & gt; Add (" select distinct city from the authors where state='" + node [I] - & gt; The Text + "'");
ADOQuery1 - & gt; The Open ();
while(! ADOQuery1 - & gt; Eof) {
TreeView1 - & gt; The Items - & gt; AddChild (node [I], ADOQuery1 - & gt; FieldByName (" city ") - & gt; AsString) are identical.
ADOQuery1 - & gt; MoveBy (1);
}
}

//initialization list column name
StringGrid1 - & gt; Cells [0] [1]="au_id";
StringGrid1 - & gt; Cells [0] [2]="au_fname";
StringGrid1 - & gt; Cells [0] [3]="au_lname";
StringGrid1 - & gt; Cells [0] [4]="phone";

StringGrid2 - & gt; Cells [0] [1]="au_id";
StringGrid2 - & gt; Cells [0] [2]="au_fname";
StringGrid2 - & gt; Cells [0] [3]="au_lname";
StringGrid2 - & gt; Cells [0] [4]="phone";
Int Rows1=1;
while(! ADOQuery1 - & gt; Eof) {
StringGrid1 - & gt; Cells [1] [Rows1]=ADOQuery1 - & gt; FieldByName (" au_id ") - & gt; AsString;
StringGrid1 - & gt; Cells [2] [Rows1]=ADOQuery1 - & gt; FieldByName (" au_lName ") - & gt; AsString;
StringGrid1 - & gt; Cells [3] [Rows1]=ADOQuery1 - & gt; FieldByName (" au_fName ") - & gt; AsString;
StringGrid1 - & gt; Cells [4] [Rows1]=ADOQuery1 - & gt; FieldByName (" phone ") - & gt; AsString;
ADOQuery1 - & gt; MoveBy (1);
Rows1 + +;
}

AnsiString ssql4="select * from the authors where state='" + node [0] - & gt; The Text + "' order by au_lname";
ADOQuery1 - & gt; Close ();
ADOQuery1 - & gt; SQL - & gt; The Clear ();
ADOQuery1 - & gt; SQL - & gt; Add (ssql4);
ADOQuery1 - & gt; The Open ();

Int Rows2=1;
while(! ADOQuery1 - & gt; Eof) {
StringGrid2 - & gt; Cells [1] [Rows2]=ADOQuery1 - & gt; FieldByName (" au_lName ") - & gt; AsString;
StringGrid2 - & gt; Cells [2] [Rows2]=ADOQuery1 - & gt; FieldByName (" au_fName ") - & gt; AsString;
StringGrid2 - & gt; Cells [3] [Rows2]=ADOQuery1 - & gt; FieldByName (" au_id ") - & gt; AsString;
StringGrid2 - & gt; Cells [4] [Rows2]=ADOQuery1 - & gt; FieldByName (" phone ") - & gt; AsString;
ADOQuery1 - & gt; MoveBy (1);
Rows2 + +;
}





}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Void __fastcall TForm1: : TreeView1Click (TObject * Sender)
{
TTreeNode * aNode=TreeView1 - & gt; Selected;
Int r1=1;
for(int i=1; iStringGrid1 - & gt; Rows [I] - & gt; The Clear ();
StringGrid2 - & gt; Rows [I] - & gt; The Clear ();
}

AnsiString ssql1;
ssql1="select * from the authors where city='" + aNode & gt; The Text + "' order by au_id"; //run, refers to the line
ADOQuery1 - & gt; Close ();
ADOQuery1 - & gt; SQL - & gt; The Clear ();
ADOQuery1 - & gt; SQL - & gt; Add (ssql1);
ADOQuery1 - & gt; The Open ();

while(! ADOQuery1 - & gt; Eof) {
TreeView1 - & gt; The Items - & gt; AddChild (aNode, ADOQuery1 - & gt; FieldByName (" city ") - & gt; AsString) are identical.
ADOQuery1 - & gt; MoveBy (1);
}

while(! ADOQuery1 - & gt; Eof) {
StringGrid1 - & gt; Cells (r1) [1]=ADOQuery1 - & gt; FieldByName (" au_id ") - & gt; AsString;
StringGrid1 - & gt; Cells (r1) [2]=ADOQuery1 - & gt; FieldByName (" au_lname ") - & gt; AsString;
StringGrid1 - & gt; Cells (r1) [3]=ADOQuery1 - & gt; FieldByName (" au_fname ") - & gt; AsString;
StringGrid1 - & gt; Cells (r1) [4]=ADOQuery1 - & gt; FieldByName (" phone ") - & gt; AsString;
ADOQuery1 - & gt; MoveBy (1);
R1 + +;
}
Int r2=1;
AnsiString ssql2="select * from the authors where state='" + aNode & gt; The Text + "' order by au_fname";
ADOQuery1 - & gt; Close ();
ADOQuery1 - & gt; SQL - & gt; The Clear ();
ADOQuery1 - & gt; SQL - & gt; Add (ssql2);
ADOQuery1 - & gt; The Open ();

while(! ADOQuery1 - & gt; Eof) {
StringGrid2 - & gt; Cells (r2) [1]=ADOQuery1 - & gt; FieldByName (" au_id ") - & gt; AsString;
StringGrid2 - & gt; Cells (r2) [2]=ADOQuery1 - & gt; FieldByName (" au_lname ") - & gt; AsString;
StringGrid2 - & gt; Cells (r2) [3]=ADOQuery1 - & gt; FieldByName (" au_fname ") - & gt; AsString;
StringGrid2 - & gt; Cells (r2) [4]=ADOQuery1 - & gt; FieldByName (" phone ") - & gt; AsString;
ADOQuery1 - & gt; MoveBy (1);
R2 + +;
}
Int r3=1;

ADOQuery1 - & gt; Close ();
ADOQuery1 - & gt; SQL - & gt; The Clear ();
ADOQuery1 - & gt; SQL - & gt; Add (" select * from the authors where state='" + aNode & gt; The Text + "' order by au_id");
ADOQuery1 - & gt; The Open ();


while(! ADOQuery1 - & gt; Eof) {

StringGrid1 - & gt; Cells [1] [r3]=ADOQuery1 - & gt; FieldByName (" au_id ") - & gt; AsString;
StringGrid1 - & gt; Cells [2] [r3]=ADOQuery1 - & gt; FieldByName (" au_lname ") - & gt; AsString;
StringGrid1 - & gt; Cells [3] [r3]=ADOQuery1 - & gt; FieldByName (" au_fname ") - & gt; AsString;
StringGrid1 - & gt; Cells [4] [r3]=ADOQuery1 - & gt; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related