Page 1 of 1

How can I get results from query?

Posted: Thu 31 May 2007 15:17
by simveck
How can I get results from query?
everything is OK with insert or remove, but when I want to get records from database I don't know how

TStrings *String;
MyQuery1->SQL->Add("select rating from ratings;");
MyQuery1->Execute();

AnsiString str = MyQuery1->GetDetailLinkFields(String,"rating","ratings");

or something i do wrong, I want to get results from database when i use select

Re: How can I get results from query?

Posted: Fri 01 Jun 2007 00:18
by eduardosic
simveck wrote:How can I get results from query?
everything is OK with insert or remove, but when I want to get records from database I don't know how

TStrings *String;
MyQuery1->SQL->Add("select rating from ratings;");
MyQuery1->Execute();

AnsiString str = MyQuery1->GetDetailLinkFields(String,"rating","ratings");

or something i do wrong, I want to get results from database when i use select
MyQuery1->SQL->Add("select rating from ratings;");
MyQuery1->Execute();
Str = MyQuery1->FieldByName( 'FieldName' ).AsString;

Posted: Fri 01 Jun 2007 07:10
by Antaeus
This question concerns common issues of using TDataSet. You can read more about this in the Delphi help.
In your case you can use something like this:

Code: Select all

 AnsiString str = MyQuery1->FieldByName("rating")->AsString; 
Use TDataSet->Next to scroll to the next record in the recordset.