
注:SQL TOOLS在我的程序。
请耐心读我的问题,谢谢!
void __fastcall TMainForm:: test(String Sql)
{
TADOQuery *ADOQuery=new TADOQuery(NULL);
ADOQuery->ConnectionString=MainForm->ADOConnectionStr;
ADOQuery->SQL->Clear();
ADOQuery->SQL->Add(Sql);
try{
ADOQuery->Open();
if(ADOQuery->Active){
ADOQuery->DisableControls();
while(!ADOQuery->Eof){
ShowMessage(MainForm->ADOQuery1->Fields->Fields[0]->AsString);
ADOQuery->Next();
}
ADOQuery->EnableControls();
}
}
catch(Exception &exception){
ShowMessage("error");
}
ADOQuery->Close();
delete ADOQuery;
}
//-----------------------------------------
void __fastcall TMainForm::Button1Click(TObject *Sender)
{
String Sql1="Select * from
a@db1 where rownum<4";
//只用一个DBLINK @db1 以下查询正确
test(Sql1);
}
void __fastcall TMainForm::Button2Click(TObject *Sender)
{
String Sql2="Select a.*,b.* from
a@db1, b@db2 where rownum<4";
//用两个DBLINK @db1、@db2 以下查询出错:Data type is not supported!
test(Sql2);
}
===================================================================================
如果test() 中ADOQuery不是动态申请,即将删除“TADOQuery *ADOQuery=new TADOQuery(NULL);”
ADOQuery控制在设计期在FORM上拖一个,那么test(Sql2)也能正确执行。====================================================================================
我找不出原因,难道是ADOQuery的问题?
有人会说:那就在FORM上拖一个ADOQuery呗?
不行啊,我是多线程并发查询的,所以只能 new TADOQuery。
有什么办法解决?谢谢!!!!