Page 1 of 1

Stored procedures and MS-SQL

Posted: 11.04.2006, 08:11
by PiSymbol
Dear Visitors,

I'm using C++ Builder 6.0 Enterprise and Zeos DBO v6.5.1 alpha. I'm trying to retreive the result of an stored procedure of a MS-SQL database.

The following code doesn't work properly: (The result is empty)

Code: Select all

MS-SQL Query: 
  exec test (test contains three times a 'select')

C++ source:
  ZConnection1->Connect();
  if(ZConnection1->Connected)
        {
          ZQuery1->Close();
          ZQuery1->SQL->Clear();
          ZQuery1->SQL->Text = queryMemo->Text.Trim();
          ZQuery1->Close();
          ZQuery1->Open();
          ZQuery1->FindFirst();

          while(ZQuery1->Eof == false)
                {
                  for(int i=1; i<ZQuery1->FieldDefList->Count + 1; i++)
                        {
                          resultMemo->Lines->Add(ZQuery1->Fields->FieldByNumber(i)->AsString);
                        }
                  ZQuery1->Next();
                }
          ZQuery1->Close();
          ZConnection1->Disconnect();
        }
Could someone please explain what's wrong? Do I need to use 'ZStoreProc' instead of 'ZQuery'?

Thanks in advance for your help!

Ps. The Stored Procedure works properly in other applications

Posted: 12.04.2006, 21:03
by PiSymbol
Could someone explain how I can use 'Stored Procedures'?

Thanks!