After connecting to a Firebird database with C++ builder, I cannot get a result from a simple select request.
I have some confusion about a lot of members of classes:
void __fastcall TForm2::btn1Click(TObject *Sender)
{ TSQLConnection co = new TSQLConnection(this);
Base_Firebird *fb = new Base_Firebird() ;
bool bl = fb->Connecter(co);
String sqlstring = "select nom_action from T_ACTION where CLE_ACTION=6 ";
if (bl)
TSQLQuery *req = new TSQLQuery(NULL) ;
req->SQLConnection = co ;
req->SQL->Add(sqlstring);
req->Open() ;
}
My problem is here after opening the TSQLQuery, I don't know how I can get the result and execute the command.
Read Embarcadero's documentation. There are whole chapters on how to work the SQL components you are using, including:
How To Perform Database Procedures
Using dbExpress Components Index
For example:
void __fastcall TForm2::btn1Click(TObject *Sender)
{
TSQLConnection *co = new TSQLConnection(NULL);
Base_Firebird *fb = new Base_Firebird();
if (fb->Connecter(co))
{
TSQLQuery *req = new TSQLQuery(NULL);
req->SQLConnection = co;
req->SQL->Text = "select nom_action from T_ACTION where CLE_ACTION=6";
req->Open();
while (!req->Eof)
{
// use req->Fields as needed...
req->Next();
}
delete req;
}
delete fb;
delete co;
}