none
Procedure or function Company_CreateCompany has too many arguments specified. RRS feed

  • Question

  • I'm having a problem which the error is Procedure or function Company_CreateCompany has too many arguments specified. I'm using Stored Procedure (SP) to receive input from interface and  retrieve an output from the SP. Can somebody help me with the error.

    public string _connectionString = ConfigurationManager.ConnectionStrings["SQLConn"].ConnectionString;

     

      SqlConnection con = new SqlConnection(_connectionString);

            SqlCommand cmd = new SqlCommand("Company_CreateCompany", con);

            cmd.CommandType = CommandType.StoredProcedure;

     

            try

            {

                /*

                @CompanyName VARCHAR(150) ,

                @RegistrationNo VARCHAR(30) ,

                @CompanyCode VARCHAR(10) ,

                @ShortName VARCHAR(20) ,

                @CompanyType VARCHAR(1) ,

                @CompanyId INT OUTPUT

                 */

                cmd.Parameters.Add("@CompanyType", SqlDbType.VarChar).Value = DDLCompanyType.Text;

                cmd.Parameters.Add("@CompanyName", SqlDbType.VarChar).Value = txtCompanyName.Text;

                cmd.Parameters.Add("@RegistrationNo", SqlDbType.VarChar).Value = txtRegNo.Text;

                cmd.Parameters.Add("@AccountNumber", SqlDbType.VarChar).Value = txtAccountNo.Text;

                cmd.Parameters.Add("@CompanyCode", SqlDbType.VarChar).Value = txtCompanyCode.Text;

                cmd.Parameters.Add("@ShortName", SqlDbType.VarChar).Value = txtShortName.Text;

     

                SqlParameter param = new SqlParameter("@CompanyId", SqlDbType.Int);

                param.Direction = ParameterDirection.Output;

                cmd.Parameters.Add(param);

     

                con.Open();

                cmd.ExecuteScalar();

                Response.Write("Record Updated");

            }

            catch (Exception ex)

            {

                lblMsg.Text = ex.Message;

            }

            finally

            {

                con.Close();

                con.Dispose();

            }

     

    Monday, August 2, 2010 8:13 AM

Answers

All replies