在使用c+执行请求后,如何获得请求的结果+;建筑商XE6和火鸟? 用C++ Builder连接到FielBooDebug数据库后,无法从简单的选择请求中得到结果。
我对很多班级成员感到困惑:在使用c+执行请求后,如何获得请求的结果+;建筑商XE6和火鸟? 用C++ Builder连接到FielBooDebug数据库后,无法从简单的选择请求中得到结果。,c++,sql,firebird,dbexpress,c++builder-xe6,C++,Sql,Firebird,Dbexpress,C++builder Xe6,我对很多班级成员感到困惑: 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_
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() ;
}
我的问题是在打开TSQLQuery后,我不知道如何获得结果并执行命令。尝试将子例程的结尾更改为以下内容:
if (bl)
{ /// you forgot compound operator here !!!!!
TSQLQuery *req = new TSQLQuery(this) ;
req->SQLConnection = co ;
req->SQL->Text = sqlstring;
req->Open() ;
int j = 0;
while( !req->EOF() )
{
++j;
String Value = req->Fields[0]->AsString;
ShowMessageFmt( "Row %d ==> Value: %s ", ARRAYOFCONST(( j, Value )) );
// String MSG = Format( "Row %d ==> Value: %s ", ARRAYOFCONST(( j, Value )) );
// ShowMessage( MSG );
req -> Next();
};
req->Close();
ShowMessage("Data over.");
}
req -> Free(); // maybe "delete req;" would work too, dunno
}
检查:
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;
}
谷歌和阅读德尔福介绍文章和书籍。它是C++ Builder及其库的主要语言,因此你会得到更多的搜索结果。在阅读了基本的Delphi代码之后,你就可以在没有任何显著的努力的情况下编写相等的基本C++代码。什么是‘BaseIiFixBuy’??BaseFixBuy是我在CaseSaseB.CPP中声明的一个对象,在我声明的类的声明中,它被称为连接器(TSQL连接)。我相信我正在工作:Dyou也可以在///上查看ADO示例,虽然Delphi中的ADO与dbExpress(您使用的库)并不完全相同,但应该有相似之处这不是您真正的代码。它没有编译,里面有几个打字错误。