Board index » delphi » TIBx Query no result on good query
RWatkins
![]() Delphi Developer |
TIBx Query no result on good query2003-10-07 06:39:43 AM delphi50 I am having great success in using TIBBlobStream, TIBSQL for executed statements, and TIBQuery for updating blobs in fields taken from TIBTable Locate commands. However, TIBQuery and TIBDataSet don't seem to return meaningful results from a fairly simple SELECT query, and I am stymied. Can anyone help? Sample results and code follow. The TIBx database, transaction and query were set up as described in the Help file "Getting started with InterBase Express". The TQuery was set up to the database. The username and password were entered once for the TIBx components, and again to access the TQuery component. Problem: TIBx routines are not returning a query result when querying a database. The same query done with TQuery works fine. What am I missing? Execution of the following program results in a Memo1 display of: IBTransaction1 No result: SELECT * FROM PATENT WHERE PATENTNO = '5000001' IBQuery1 No result: SELECT * FROM PATENT WHERE PATENTNO = '5000001' Got a result: 19022 //-------------------------------------------------------------------------- - #include <vcl.h> #pragma hdrstop #include <ib.hpp> #include <ibdatabase.hpp> #include <ibtable.hpp> #include <ibquery.hpp> #include "QueryTestU.h" //-------------------------------------------------------------------------- - #pragma package(smart_init) #pragma resource "*.dfm" TQTest *QTest; //-------------------------------------------------------------------------- - __fastcall TQTest::TQTest(TComponent* Owner) : TForm(Owner) { } //-------------------------------------------------------------------------- - void __fastcall TQTest::btnQueryClick(TObject *Sender) { AnsiString workstring; workstring = "SELECT * FROM PATENT WHERE PATENTNO = '5000001'"; IBDatabase1->Connected = true; IBDataSet1->Close(); IBDataSet1->SelectSQL->Clear(); IBDataSet1->SelectSQL->Add(workstring); IBDataSet1->Prepare(); IBTransaction1->Active = true; IBDataSet1->Open(); Memo1->Clear(); if (IBDataSet1->FindFirst()) { Memo1->Lines->Add("Got a result:"); Memo1->Lines->Add(IntToStr(IBDataSet1->FieldByName("RECNO")->AsInteger)); } else { Memo1->Lines->Add("IBTransaction1 No result:"); Memo1->Lines->Add(workstring); } IBDataSet1->Close(); IBTransaction1->Active = false; IBQuery1->Close(); IBQuery1->SQL->Clear(); IBQuery1->SQL->Add(workstring); IBTransaction1->Active = true; IBQuery1->Open(); if (IBQuery1->FindFirst()) { Memo1->Lines->Add("Got a result:"); Memo1->Lines->Add(IntToStr(IBQuery1->FieldByName("RECNO")->AsInteger)); } else { Memo1->Lines->Add("IBQuery1 No result:"); Memo1->Lines->Add(workstring); } IBQuery1->Close(); IBTransaction1->Active = false; IBDatabase1->Connected = false; Query1->Close(); Query1->SQL->Clear(); Query1->SQL->Add(workstring); Query1->Open(); if (Query1->FindFirst()) { Memo1->Lines->Add("Got a result:"); Memo1->Lines->Add(IntToStr(Query1->FieldByName("RECNO")->AsInteger)); } else { Memo1->Lines->Add("No result:"); Memo1->Lines->Add(workstring); } return; } |