过程或函数SP_UpGridDateDetails指定了太多参数. [英] Procedure or function SP_UpGridDateDetails has too many arguments specified.

查看:106
本文介绍了过程或函数SP_UpGridDateDetails指定了太多参数.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,


我收到过程或函数SP_UpGridDateDetails指定了太多参数".更新网格时出现错误.

我的代码是这样的...
在数据访问层中..

Hello friends,


I am getting "Procedure or function SP_UpGridDateDetails has too many arguments specified." error when i am updating the grid.

My code like this...
In Data Access Layer..

foreach (CO_TR_Registration objCO_TR_Registration in ObjGridCO_TR_Registration)
               {


                   objSqlCommand.Parameters.Add("@regId", SqlDbType.VarChar).Value = (objCO_TR_Registration.RegistrationID);
                   objSqlCommand.Parameters.Add("@VlFNo", SqlDbType.VarChar).Value = (objCO_TR_Registration.VLFNO).TrimEnd() ;
                   objSqlCommand.Parameters.Add("@Stud_name", SqlDbType.VarChar).Value = objCO_TR_Registration.Name;
                   objSqlCommand.Parameters.Add("@FHG", SqlDbType.VarChar).Value = objCO_TR_Registration.FHG;
                   objSqlCommand.Parameters.Add("@FHG_Name", SqlDbType.VarChar).Value = objCO_TR_Registration.FatherName;
                   objSqlCommand.Parameters.Add("@MaritalStatus", DbType.String).Value = objCO_TR_Registration.MaritalStatus;
                   objSqlCommand.ExecuteNonQuery();

               }


和存储过程..


and stored procedure..

UPDATE [KMDCModified].[dbo].[Register]
   SET


       [VLFNo]=@VlFNo
      ,[stud_name] = @Stud_name
      ,[FHG] = @FHG
      ,[FHG_Name] = @FHG_Name

      ,[maritalstatus] = @maritalstatus

 WHERE regid=@regId




在secong循环中,它得到错误




in secong loop its getting error

推荐答案

由于第二个循环回合会给出错误,因此很明显:不要使用
除非在循环中也创建了新的objSqlCommand,否则在循环中
As it is the second loop round that gives the error it is fairly obvious: Don''t use
objSqlCommand.Parameters.Add("@...", SqlDbType.VarChar).Value = ...);

.

否则,您已经有一个具有该名称的参数,该参数带有一个值,只会让人感到困惑.

顺便说一句,Parameters.Add被贬值,而取而代之的是Parameters.AddWithValue,它不需要数据类型.

in your loop unless you also create a new objSqlCommand in the loop as well.

Otherwise, you already have a parameter of that name, with a value, which can only get confusing.

BTW: Parameters.Add is depreciated in favour of Parameters.AddWithValue, which does not require the datatype.


这篇关于过程或函数SP_UpGridDateDetails指定了太多参数.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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