找不到存储过程的参数 [英] Parameter of stored procedure not found

查看:227
本文介绍了找不到存储过程的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码使用 TADOStoredProc 类型

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;

参数 @Error_Number 是存储过程 UpdateErrors 使用SQL Server Management Studio,我添加了用于确认的截图图像

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

推荐答案

只需使用TADOCommand

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;

如果要修复代码

执行

 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

等的方向。还有更多工作...使用ADOCommands做第一种方式

etc. Lots more work... do the first way with ADOCommands

这篇关于找不到存储过程的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆