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
How could i select every record from table by TMyQuery?
I myself use delphi rather than C++ but the logic is the same
MyQuery1.SQL.Text := 'SELECT * FROM customer';
MyQuery1.Active := True;
While not MyQuery1.Eof do
begin
ShowMessage(MyQuery1.FieldByName("phone").AsString;
MyQuery1.Next;
end;
All kinds of dataset can work like this so your might read some database related materials for more information.
MyQuery1.SQL.Text := 'SELECT * FROM customer';
MyQuery1.Active := True;
While not MyQuery1.Eof do
begin
ShowMessage(MyQuery1.FieldByName("phone").AsString;
MyQuery1.Next;
end;
All kinds of dataset can work like this so your might read some database related materials for more information.
-
AndreyZ
Re: How could i select every record from table by TMyQuery?
It's work!
Thanks you!
Thanks you!