Page 1 of 1

Storedprocedure Parameter not found

Posted: Sun 13 Nov 2016 08:51
by RSJ Meijer
I call a storedprocedure SQL_SP_CheckVoorraadBesteld that has 3 input parameters (@sArtikelcode VarChar(30), @sDebNr VarChar(10), @sOrdernummer VarChar(10),)

The code I use:

Code: Select all

    Try
      SQL_SP_CheckVoorraadBesteld.ParamByName('@sArtikelcode').Value := 'Artcode';
      SQL_SP_CheckVoorraadBesteld.ParamByName('@sDebNr').Value := 'A123';
      SQL_SP_CheckVoorraadBesteld.ParamByName('@sOrdernummer').Value := 'O123';
      SQL_SP_CheckVoorraadBesteld.Prepared:=True;
    Except
      On E:Exception Do begin
        LogError(E);
        Application.MessageBox(PChar('Opvragen Bestelvoorraad informatie mislukt!' +#13#10+ #13#10 + 'Foutcode:! '+ E.Message +#13#10+ #13#10 + 'Opvragen bestelvoorraad mislukt'), 'Fout', MB_ICONERROR);
        Exit;
      end;
    end; // End Try/Except
When I only use 1 parameter, it works ok. But when using 2 ore more parameters I get the exception:
Exception Class: EDatabaseError; SQL_SP_CheckVoorraadBesteld: Parameter '@sDebNr' not found;

The Storedprocedure does work fine on the SQL server, i have tested this.

I have tried:

Code: Select all

      SQL_SP_CheckVoorraadBesteld.param.ParamByName('@sDebNr').Value := 'A123';
But with the same result.

I Use Delphi XE-2 with hothix 1, and DBExpress version 6.5.7.

What's wrong?
Kind regards

Robert Meijer

Re: Storedprocedure Parameter not found

Posted: Sun 13 Nov 2016 12:03
by RSJ Meijer
I have updated to DBExpress version 7.3.5, but the problem still appears.

Re: Storedprocedure Parameter not found

Posted: Mon 14 Nov 2016 09:58
by azyk
In dbExpress parameters of SQL Server stored procedures are named in such a way that they do not include a leading character @. To solve the issue, in the provided code, delete the leading character @ in the parameters names.