Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
C#
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
Posted
Updated 11-Feb-14 21:55pm
v2
Comments
Pheonyx 12-Feb-14 3:54am    
The issue is that you are supplying multiple parameters all with the same parameter name:

<pre lang="cs">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);</pre>

What is your stored procedure actually expecting? If you are expecting to be able to pass each of those values at the same time, then you need to give them different names. However, as you have shown us nothing that clarifies your stored procedure I cannot be sure what you are exactly trying to do.

Quote:
The above stored procedure occur a problem "Parameter '@PresentJobLocation' was supplied multiple times."
It is quite clear, isn't it?
C#
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.
 
Share this answer
 
Replace your stored procedure parameters as PresentJobLocation1,PresentJobLocation2,PresentJobLocation3,PresentJobLocation4,PresentJobLocation5 in SQL Stored Procedure. & replace your c# code by fallowing code.


C#
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);
       }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900