_No overload for method 'AddEmployee' takes '12' arguments_ RRS feed

  • Question

  • I  got this error  while inserting the record in database... i tried lot couldnt find the error pls any one help me pls!!!!!!!!!!!!!!!!!1

     here my Class.cs


    using System;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Text;

    using System.IO;

    using System.Data;

    using System.Data.SqlClient;

    using System.Linq;

    using System.Data.Common;

    using Microsoft.Practices.EnterpriseLibrary.Data;

    using Microsoft.Practices.EnterpriseLibrary.Data.Sql;




    namespace Application


        public class Class1


            protected Class1 oClass;

            private Database ApplnDB;


            private SqlDatabase ODB = null;



            public Class1 (string StrDatabase)


               ODB = DatabaseFactory.CreateDatabase(StrDatabase) as SqlDatabase;


            private const string USP_AddEmployeeDetails = "USP_AddEmployeeDetails";

            private const string USP_AddEmployeeDetails_Parameter1 = "@Emp_id";

            private const string USP_AddEmployeeDetails_Parameter2 = "@Emp_name";

            private const string USP_AddEmployeeDetails_Parameter3 = "@Dateofjoining";

            private const string USP_AddEmployeeDetails_Parameter4 = "@Designation";

            private const string USP_AddEmployeeDetails_Parameter5 = "@Experience";

            private const string USP_AddEmployeeDetails_Parameter6 = "@Department";

            private const string USP_AddEmployeeDetails_Parameter7 = "@GSalary";

            private const string USP_AddEmployeeDetails_Parameter8 = "@Location";

            private const string USP_AddEmployeeDetails_Parameter9 = "@PF";

            private const string USP_AddEmployeeDetails_Parameter10 = "@NetSalary";

            private const string USP_AddEmployeeDetails_Parameter11 = "@ProfessionalTax";

            private const string USP_AddEmployeeDetails_Parameter12 = "@Total";




            public void AddEmployee(string Emp_id,

                                    string Emp_name,

                                    DateTime Dateofjoining,

                                    string Designation,

                                    string Experience,

                                    string Department,

                                    long GSalary,

                                    string Location,

                                    long PF,

                                    long NetSalary,

                                    long ProfessionalTax,

                                    long Total)


                DbCommand oCommand = ODB.GetStoredProcCommand(USP_AddEmployeeDetails);

                ODB.AddInParameter(oCommand, USP_AddEmployeeDetails_Parameter1, DbType.String, Emp_id);

                ODB.AddInParameter(oCommand, USP_AddEmployeeDetails_Parameter2, DbType.String, Emp_name);

                ODB.AddInParameter(oCommand, USP_AddEmployeeDetails_Parameter3, DbType.DateTime, Dateofjoining);

                ODB.AddInParameter(oCommand, USP_AddEmployeeDetails_Parameter4, DbType.String, Designation);

                ODB.AddInParameter(oCommand, USP_AddEmployeeDetails_Parameter5, DbType.String, Experience);

                ODB.AddInParameter(oCommand, USP_AddEmployeeDetails_Parameter6, DbType.String, Department);

                ODB.AddInParameter(oCommand, USP_AddEmployeeDetails_Parameter7, DbType.Int64, GSalary);

                ODB.AddInParameter(oCommand, USP_AddEmployeeDetails_Parameter8, DbType.String, Location);

                ODB.AddInParameter(oCommand, USP_AddEmployeeDetails_Parameter9, DbType.Int64, PF);

                ODB.AddInParameter(oCommand, USP_AddEmployeeDetails_Parameter10, DbType.Int64, NetSalary);

                ODB.AddInParameter(oCommand, USP_AddEmployeeDetails_Parameter11, DbType.Int64, ProfessionalTax);

                ODB.AddInParameter(oCommand, USP_AddEmployeeDetails_Parameter12, DbType.Int64,Total);





    my Default.aspx page

    using System;

    using System.Configuration;

    using System.Data;

    using System.Linq;

    using System.Web;

    using System.Web.Security;

    using System.Web.UI;

    using System.Web.UI.HtmlControls;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

    using System.Xml.Linq;

    using System.Data.SqlClient;

    using Ap = Application;


    public partial class _Default : System.Web.UI.Page


        protected Ap.Class1 oClass;

        protected void Page_Load(object sender, EventArgs e)


            oClass = new Ap.Class1(constant.ApplicationDB);

            if (!IsPostBack)








        protected void Button1_Click1(object sender, EventArgs e)


            string Emp_id = txt_Emp_id.Text;

            string Emp_name = txt_Emp_name.Text;

            //DateTime Dateofjoining = Convert.ToDateTime(txt_doj.Text);

            DateTime Dateofjoining = Convert.ToDateTime(txt_doj.Text.Trim());

            string Designation = txt_des.Text;

            string Experience = drl_exp.Text;

            string Department = drl_dept.Text;

            long GSalary = Convert.ToInt64(txt_gsal.Text);

            string Location = drl_loc.Text;

            Decimal PF = Convert.ToDecimal(txt_pf.Text);

            long NetSalary = Convert.ToInt64(txt_netsal.Text);

            long ProfessionalTax = Convert.ToInt64(drl_tax.Text);

            long Total = Convert.ToInt64(txt_total.Text);



















                txt_Emp_id.Text = " ";

                txt_Emp_name.Text = " ";

                txt_doj.Text = " ";

                txt_des.Text = " ";

                txt_gsal.Text = " ";

                txt_pf.Text       = " ";

                txt_netsal.Text     = " ";

                txt_total.Text    = " ";









        protected void Button2_Click1(object sender, EventArgs e)



            txt_Emp_id.Text = " ";

            txt_Emp_name.Text = " ";

            txt_doj.Text = " ";

            txt_des.Text = " ";

            txt_gsal.Text = " ";

            txt_pf.Text = " ";

            txt_netsal.Text = " ";

            txt_total.Text = " ";








        protected void Button3_Click(object sender, EventArgs e)










        protected void Button4_Click(object sender, EventArgs e)














    Pls Try to reply sooooooooooooooooon






    Saturday, September 18, 2010 6:46 AM


  • Has to be your line that starts with oClass.AddEmployee.  You have too many parameters or a missing a parameter.  This happens to everyone, and sometimes it is hard to see what is wrong when the method has a lot of parameters.  When frustration takes over, what I usually do is attempt to write the line again from scratch.

    Another thing, if the class is in a separate DLL, perhaps you did not compile the DLL after adding or removing a parameter, or your application is referencing an old version of the DLL.  Another ticket for similar frustrations!




    Saturday, September 18, 2010 1:49 PM