如何修复“?在集合中找不到idparam“在mysql中插入存储过程 [英] How to fix "? idparam not found in collection" in mysql insert stored proc

查看:86
本文介绍了如何修复“?在集合中找不到idparam“在mysql中插入存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am writing an insert query in mysql stored procedure .when i am trying to run i am getting error "?IDparam not found in collection" .I didnt give ID in insert as it should be autoincremented and i use it in update and delete later in this procedure.

This is Insert query from my proc: 
<pre>CREATE DEFINER=`root`@`%` PROCEDURE `insertproc`(
IN IDparam INT,
IN Pathparam VARCHAR(100),
IN fileNameparam VARCHAR(100),
IN Countparam VARCHAR(100),
IN CreatedBYparam DATETIME,
IN CreatedDateparam DATETIME,
IN Typeparam VARCHAR(100),
IN Statusparam VARCHAR(100),
IN crudparam VARCHAR(50))
BEGIN

IF(crudparam ='INSERT')
THEN
INSERT INTO pathmaster (
                        Path,
                        pathName,
                       fileName ,
                       Count,
                       CreatedBY,
                       CreatedDate,
                       Type,
                       Status
                        )
                        VALUES(
                             Pathparam,
                         (Select MAX(pathName) from pathmaster)+1,
                       FileNameparam,
                      Countparam,
                      CreatedBYparam,
                    CreatedDateparam,
                    Typeparam,
                    Statusparam
                );
END IF;





以下是拨打SP的代码



below is code to call SP

 MySqlParameter[] mysqlparam = new MySqlParameter[]
  {
     new MySqlParameter("Pathparam",Path.Trim()),

    new MySqlParameter("FileNameparam",filename.Trim()),
    new MySqlParameter("Countparam",count),
    new MySqlParameter("CreatedBYparam",date),
    new MySqlParameter("CreatedDateparam",date),
   new MySqlParameter("Typeparam",strType),
new MySqlParameter("Statusparam","pending"), 
    new MySqlParameter("ACTIONparam","INSERT")
   };
      ds = ExecuteProc("insertproc", mysqlparam);





所以可能是什么问题



我尝试过:



将ID列更改为varchar无效。参数中没有任何空格。



so what may be the problem

What I have tried:

change ID column to varchar didnt work. there are no any whitespaces in parameters.

推荐答案

您的存储过程声明一个名为 IDParam 的参数。您的C#代码没有。



您的存储过程声明一个名为 crudparam 的参数。您的C#代码没有。



您的C#代码传递一个名为 ACTIONparam 的参数。您的存储过程没有这样的参数。



从C#代码必须传递给存储过程的参数列表与列表相匹配该存储过程的参数。你必须为每个没有默认值的入站存储过程参数传递一个值。



因为你没有使用 IDParam 在存储过程中,您只需要从存储过程定义中删除该参数。
Your stored procedure declares a parameter called IDParam. Your C# code does not.

Your stored procedure declares a parameter called crudparam. Your C# code does not.

Your C# code passes in a parameter called ACTIONparam. Your stored procedure has no such parameter.

The list of parameters you pass to the stored procedure from your C# code MUST match the list of parameters for that stored procedure. You MUST pass a value for every inbound stored procedure parameter which does not have a default value.

Since you're not using IDParam within the stored procedure, you simply need to remove the parameter from the stored procedure definition.


这篇关于如何修复“?在集合中找不到idparam“在mysql中插入存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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