存储过程问题 [英] stored procedure problem

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

问题描述

 Public_Candidate_result obj =  new  Public_Candidate_result(); 
尝试
{
Connection = ConfigurationManager.AppSettings [ < span class =code-string> mycon];
string [] splitvalue = value .Split(' @');

delhi = splitvalue [ 0 ];
kochi = splitvalue [ 1 ];
mumbai = splitvalue [ 2 ];
chennai = splitvalue [ 3 ];
banglore = splitvalue [ 4 ];

SqlParameter [] location_para = new SqlParameter [ 6 ];

location_para [ 0 ] = new SqlParameter( @ PresentJobLocation,delhi);
location_para [ 1 ] = new SqlParameter( @ PresentJobLocation,kochi);
location_para [ 2 ] = new SqlParameter( @ PresentJobLocation,mumbai);
location_para [ 3 ] = new SqlParameter( @ PresentJobLocation,chennai);
location_para [ 4 ] = new SqlParameter( @ PresentJobLocation,banglore);
location_para [ 5 ] = new SqlParameter( @ intmode 6 );





以上存储过程出现问题参数'@PresentJobLocation'多次提供。..如何清除问题

解决方案

Quote:

上述存储过程出现问题参数'@PresentJobLocation'多次提供。

很明显,不是吗?

 location_para [ 0 ] =  new  SqlParameter(  @ PresentJobLocation,delhi); 
location_para [ 1 ] = new SqlParameter( @ PresentJobLocation,kochi);
location_para [ 2 ] = new SqlParameter( @ PresentJobLocation,mumbai);
location_para [ 3 ] = new SqlParameter( @ PresentJobLocation,chennai);
location_para [ 4 ] = new SqlParameter( @ PresentJobLocation,banglore);



你应该定义参数一次,不超过。



查看存储过程并查看参数的数量它期待。从代码后面传递参数的数量


将存储过程参数替换为PresentJobLocation1,PresentJobLocation2,PresentJobLocation3,PresentJobLocation4,PresentJobLocation5 < b>在SQL存储过程中。 &通过暂停代码替换 c#代码





 Public_Candidate_result obj =  new  Public_Candidate_result(); 
尝试
{
Connection = ConfigurationManager.AppSettings [ < span class =code-string> mycon];
string [] splitvalue = value .Split(' @');

delhi = splitvalue [ 0 ];
kochi = splitvalue [ 1 ];
mumbai = splitvalue [ 2 ];
chennai = splitvalue [ 3 ];
banglore = splitvalue [ 4 ];

SqlParameter [] location_para = new SqlParameter [ 6 ];

location_para [ 0 ] = new SqlParameter( @ PresentJobLocation1,delhi);
location_para [ 1 ] = new SqlParameter( @ PresentJobLocation2,kochi);
location_para [ 2 ] = new SqlParameter( @ PresentJobLocation3,mumbai);
location_para [ 3 ] = new SqlParameter( @ PresentJobLocation4,chennai);
location_para [ 4 ] = new SqlParameter( @ PresentJobLocation5,banglore);
location_para [ 5 ] = new SqlParameter( @ intmode 6 );
}


Public_Candidate_result obj = new Public_Candidate_result();
        try
        {
            Connection = ConfigurationManager.AppSettings["mycon"];
            string[] splitvalue = value.Split('@');

            delhi = splitvalue[0];
            kochi = splitvalue[1];
            mumbai = splitvalue[2];
            chennai = splitvalue[3];
            banglore = splitvalue[4];

            SqlParameter[] location_para = new SqlParameter[6];

            location_para[0] = new SqlParameter("@PresentJobLocation", delhi);
            location_para[1] = new SqlParameter("@PresentJobLocation", kochi);
            location_para[2] = new SqlParameter("@PresentJobLocation", mumbai);
            location_para[3] = new SqlParameter("@PresentJobLocation", chennai);
            location_para[4] = new SqlParameter("@PresentJobLocation", banglore);
            location_para[5] = new SqlParameter("@intmode", 6);



The above stored procedure occur a problem "Parameter '@PresentJobLocation' was supplied multiple times."..how to clear thiz problem

解决方案

Quote:

The above stored procedure occur a problem "Parameter '@PresentJobLocation' was supplied multiple times."

It is quite clear, isn't it?

location_para[0] = new SqlParameter("@PresentJobLocation", delhi);
location_para[1] = new SqlParameter("@PresentJobLocation", kochi);
location_para[2] = new SqlParameter("@PresentJobLocation", mumbai);
location_para[3] = new SqlParameter("@PresentJobLocation", chennai);
location_para[4] = new SqlParameter("@PresentJobLocation", banglore);


You should define the Parameter once, not more than that.

Look at your Stored Procedure and check how many Parameters it expects. Pass those number of Parameters from Code behind.


Replace your stored procedure parameters as PresentJobLocation1,PresentJobLocation2,PresentJobLocation3,PresentJobLocation4,PresentJobLocation5 in SQL Stored Procedure. & replace your c# code by fallowing code.


Public_Candidate_result obj = new Public_Candidate_result();
       try
       {
           Connection = ConfigurationManager.AppSettings["mycon"];
           string[] splitvalue = value.Split('@');

           delhi = splitvalue[0];
           kochi = splitvalue[1];
           mumbai = splitvalue[2];
           chennai = splitvalue[3];
           banglore = splitvalue[4];

           SqlParameter[] location_para = new SqlParameter[6];

           location_para[0] = new SqlParameter("@PresentJobLocation1", delhi);
           location_para[1] = new SqlParameter("@PresentJobLocation2", kochi);
           location_para[2] = new SqlParameter("@PresentJobLocation3", mumbai);
           location_para[3] = new SqlParameter("@PresentJobLocation4", chennai);
           location_para[4] = new SqlParameter("@PresentJobLocation5", banglore);
           location_para[5] = new SqlParameter("@intmode", 6);
       }


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

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