Storedprocedure Parameter not found

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
RSJ Meijer
Posts: 2
Joined: Sun 13 Nov 2016 07:45

Storedprocedure Parameter not found

Post by RSJ Meijer » Sun 13 Nov 2016 08:51

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

RSJ Meijer
Posts: 2
Joined: Sun 13 Nov 2016 07:45

Re: Storedprocedure Parameter not found

Post by RSJ Meijer » Sun 13 Nov 2016 12:03

I have updated to DBExpress version 7.3.5, but the problem still appears.

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Storedprocedure Parameter not found

Post by azyk » Mon 14 Nov 2016 09:58

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.

Post Reply