问题
I use the following code to call my stored procedure using TADOStoredProc
type
MySP.Connection := aConnection;
MySP.ProcedureName := 'dbo.UpdateErrors';
MySP.Parameters.ParamByName('@Error_Number').value := -1;
MySP.Parameters.ParamByName('@NewError_Name').value := 'errorM1';
MySP.Parameters.Refresh;
MySP.ExecProc;
The parameter @Error_Number
is part of the stored procedure UpdateErrors
using SQL Server Management Studio, I add snip image for confirmation
but I can't understand why I get an error
回答1:
Simply use a TADOCommand
MyCommand.Connection := aConnection;
MyCommand.CommandText := 'EXEC dbo.UpdateErrors :Er, :Na'; //you can call the params what you want
MyCommand.Parameters[0].value := -1; //Or you can do ParamByNname and use Er and Na (or whatever you called your params) instead of indices
MyCommand.Parameters[1].value := 'errorM1';
MyCommand.Execute;
If you want to fix your code
Do
ErParam := MySP.Parameter.Add;
ErParam.Name := '@Error_Number';
ErParam.DataType := ftInteger; //put your correct type here
ErParam.Direction := pdInput; //set your direction for the param
etc. Lots more work... do the first way with ADOCommands
来源:https://stackoverflow.com/questions/31903397/parameter-of-stored-procedure-not-found