Can not open a Resultset

Forum related to MS SQL Server

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
fredycc
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: 18.01.2010, 16:48

Can not open a Resultset

Post by fredycc »

Hi boys I have a problem with Zeos 6.6.6-stable & FPC 2.2.4(windows 7) & SQL server 2005; I have created a SP like this:
//Is a simple SP to return a integer
ALTER PROCEDURE [dbo].[BuscaTarCta](
@Tar VARCHAR(18),
@Cta VARCHAR(18),
@Res Integer OUTPUT )
AS

SET NOCOUNT ON;

Select @Res = COUNT(SM.NumTar) From tMKStockMon SM
Where SM.NumTar = @Tar And SM.NumCuenta = @Cta

The problem is when I try to execute the SP into my application, I did this:

ZStoredProc2.StoredProcName := 'BuscaTarCta';
ZStoredProc2.ParamByName('@Res').ParamType := ptOutput;
ZStoredProc2.ParamByName('@Tar').ParamType := ptInput;
ZStoredProc2.ParamByName('@Cta').ParamType := ptInput;

ZStoredProc2.ParamByName('@Tar').Value:= StringGrid3.Cells[2,i];
ZStoredProc2.ParamByName('@Cta').Value := StringGrid3.Cells[3,i];
ZStoredProc2.Open;

Showmessage(ZStoredProc2.FieldByName('@Res').AsInteger)

When the application try to execute with: ZStoredProc2.Open; launch a message error: Can not open a Resultset.

I have tried using ExecProc but When I try to obtain the value, a error message appear: Field @Res not found. :(
fredycc
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: 18.01.2010, 16:48

SOLVED

Post by fredycc »

I found the solution, my mistake is my sp, I modify it and works. :oops:
Post Reply