I use the following code to call my stored procedure using TADOStoredProc
type
我使用以下代码使用TADOStoredProc类型调用我的存储过程
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
参数@Error_Number是使用SQL Server Management Studio的存储过程UpdateErrors的一部分,我添加了剪辑图像以进行确认
but I can't understand why I get an error
但我不明白为什么我会收到错误
1 个解决方案
#1
2
Simply use a TADOCommand
只需使用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
还有更多的工作......用ADOCommands做第一种方式
#1
2
Simply use a TADOCommand
只需使用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
还有更多的工作......用ADOCommands做第一种方式