Click here to Skip to main content
15,886,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi all,


i got the given error in my project , the error is like this, please do a favour for me...


The best overloaded method match for 'clsCommon.FnUpdatedAccessNo(string, string, string, string)' has some invalid arguments


Source Error:

Line 170: }
Line 171: string[] result1=new string[2];
Line 172: result1 = clsObj.FnUpdatedAccessNo(Session["User_id"], accessnumber, TextBoxDest.Text.Trim(), TextBoxRef.Text.Trim());
Line 173: GridView1.EditIndex = -1;
Line 174: lblStatus.Text = "";


my code is:


C#
protected void BtnAllocate_Click(object sender, EventArgs e)
    {
      
            string[] result=new string [4];
            string accessnumber = null;
            accessnumber = "";
            result = clsObj.FnCheckAccessNo();

            if (result[0] == "1")
            {
                accessnumber = result[2];
            }
            else if (result[0] == "0")
            {
                lblStatus.Text = "";
            }
            string[] result1=new string[2];
            result1 = clsObj.FnUpdatedAccessNo(Session["User_id"], accessnumber, TextBoxDest.Text.Trim(), TextBoxRef.Text.Trim());
            GridView1.EditIndex = -1;
            lblStatus.Text = "";

}


class file is:

C#
public string[] FnUpdatedAccessNo(string Account, string AccNo, string DestNo, string DestRef)
   {

       string[] result = new string[2];
       string[] spexec = new string[2];

       string[] inputparaname = { "@Accountnumber", "@AccessNo", "@DestNo", "@name_of_diverison" };
       string[] inputparavalue = { Account, AccNo, DestNo, DestRef };

       string[] outputparaname = { "@result" };



       spexec = fnProcessStoredProc("Update_AccessNumber", sqlconn_cmsstr, inputparaname, inputparavalue, outputparaname);


       if (spexec[0] == "1" && spexec[1] == "1")
       {
           //successful login
           //if user enters valid username and password result is >1
           result[0] = "1";
           result[1] = "1";

           return result;
       }
       else if (spexec[0].ToString() == "1" && spexec[1].ToString() == "0")
       {
           result[0] = "0";
           result[1] = "0";
           return result;
       }
       else
       {
           result[0] = "0";
           result[1] = "0";
           return result;
       }
       return result;
   }
Posted

your FnUpdatedAccessNo methods first parameter is string. but Session["User_id"] is an object type. you must to convert it like this.
And dont forget when it was null it wont convert, check its nullable
C#
string userId = "";
if(Session["User_id"] != null)
userId = Session["User_id"].ToString();
else userId = "";// default value 
result1 = clsObj.FnUpdatedAccessNo(userId, accessnumber, TextBoxDest.Text.Trim(), TextBoxRef.Text.Trim());
 
Share this answer
 
C#
result1 = result1 = clsObj.FnUpdatedAccessNo(Convert.ToString(Session["User_id"]), accessnumber, TextBoxDest.Text.Trim(), TextBoxRef.Text.Trim()); 



Please check it and let me know if it helps to you.

Thanks
 
Share this answer
 
v2
Comments
stellus 27-Sep-12 10:43am    
thank you very much, now its working fine....
Strange_Pirate 29-Sep-12 6:04am    
He he ..
User's problem solved, but the person who copied from the others blog still downvote the 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