Can not open a Resultset
Posted: 06.04.2010, 22:49
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.
//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.