How could i select every record from table by TMyQuery?
Posted: Sat 19 Feb 2011 04:49
Hi all:
I have a "customer" table which have two fileds("id" and "phone").
The "id" field is auto_increment, and some records is deleted.So the table will look like this(id=1, 2, 4, 5, 7, 8 ) The records(ID=3 and 6) are deleted. How could i sequentially fetch every records without error?
.......................................................................................
MyQuery1->SQL->Clear();
MyQuery1->SQL->Add("SELECT * FROM customer");
MyQuery1->Execute();
RecCount = MyQuery1->RecordCount; //RecCount=6
for(i=1; iSQL->Clear();
MyQuery1->SQL->Add("SELECT * FROM customer WHERE id = :ID");
MyQuery1->ParamByName("ID")->AsInteger = i ;
ShowMessage(MyQuery1->FieldByName("phone")->AsString);
}
Thanks a lot
I have a "customer" table which have two fileds("id" and "phone").
The "id" field is auto_increment, and some records is deleted.So the table will look like this(id=1, 2, 4, 5, 7, 8 ) The records(ID=3 and 6) are deleted. How could i sequentially fetch every records without error?
.......................................................................................
MyQuery1->SQL->Clear();
MyQuery1->SQL->Add("SELECT * FROM customer");
MyQuery1->Execute();
RecCount = MyQuery1->RecordCount; //RecCount=6
for(i=1; iSQL->Clear();
MyQuery1->SQL->Add("SELECT * FROM customer WHERE id = :ID");
MyQuery1->ParamByName("ID")->AsInteger = i ;
ShowMessage(MyQuery1->FieldByName("phone")->AsString);
}
Thanks a lot