title: Error- Procedure or function 'hrm_Langauges' expects parameter '@CreatedOn', which was not supplied
body: <p>I am trying to delete record from grid but getting this error.</p>
  
  <p>Don't know why getting this error.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[hrm_Langauges]
  (
      @Name varchar(120),
      @CreatedOn datetime,
      @UpdatedOn datetime,
      @CreatedBy bigint=0,
      @UpdatedBy bigint=0,
      @IsDeleted bit=0,
      @status as varchar(50)
  )
  AS
  BEGIN
      BEGIN TRANSACTION
          DECLARE @ID int;
          SELECT @ID = coalesce((select max(ID) + 1 from Languages), 1)
      COMMIT   
  
      if(@status = 'Display')
      BEGIN
          SELECT * FROM [dbo].[Languages];
      END
      else if(@status = 'Add')
      BEGIN
          IF EXISTS(SELECT Name FROM [dbo].[Languages] WHERE Name = @Name)
      Begin
      Return 0
      End
      Else
          INSERT INTO [dbo].[Languages](Name,CreatedOn,CreatedBy) VALUES(@Name,@CreatedOn,@CreatedBy)
      END
      else if(@status = 'Update')
      BEGIN
          UPDATE [dbo].[Languages] Set Name=@Name,UpdatedOn=@UpdatedOn WHERE ID=@ID
      END
      else if(@status = 'Delete')
      BEGIN
          DELETE FROM [dbo].[Languages] WHERE NAME=@NAME
      END
  END
  </code></pre>
  
  <p><strong>Here is my code for delete record</strong></p>
  
  <pre><code>string strcon = ConfigurationManager.ConnectionStrings["Dbconnection"].ConnectionString;
  SqlCommand command;
  protected void Page_Load(object sender, EventArgs e)
  {
      tblAdd.Visible = false;
      Label1.Visible = false;
      //GridView1.DataBind();
      if (!Page.IsPostBack)
          {
              fillLanguageGrid();
          }
  }
  
  public void fillLanguageGrid()
      {   
          GridView1.DataSourceID = "SqlDataSource1";
          GridView1.DataBind(); 
      }
  
  protected void btnDelete_Click(object sender, EventArgs e)
  {
      foreach (GridViewRow gvrow in GridView1.Rows)
      {
          CheckBox chkdelete = (CheckBox)gvrow.FindControl("chk");
          if (chkdelete.Checked)
          {
              string name= Convert.ToString(GridView1.DataKeys[gvrow.RowIndex].Values["Name"].ToString());
             // command.Parameters.Add(new SqlParameter("@status", SqlDbType.VarChar, 50));
              deleteRecordByName(name);
          }
      }
      fillLanguageGrid();
  }
  
  public void deleteRecordByName(string Name)
  {
      SqlConnection sqlConnection = new SqlConnection(strcon);
      using (SqlCommand command = new SqlCommand("[dbo].[hrm_Langauges]", sqlConnection))
      {
          //  define this to be a stored procedure
          command.CommandType = CommandType.StoredProcedure;
          command.Parameters.Add(new SqlParameter("@status", SqlDbType.VarChar, 50));
          // define the parameter and set its value
          command.Parameters.Add(new SqlParameter("@Name", SqlDbType.VarChar)).Value = Name;
          command.Parameters["@status"].Value = "Delete";
          //open connection, execute DELETE query, close connection
          sqlConnection.Open();
          command.ExecuteNonQuery();
          sqlConnection.Dispose();
      }
  
  }
  </code></pre>
  
  <p>Can anyone suggest either my sp is not correct or my asp.net code.</p>
  
  <p>While executing code I am getting error:</p>
  
  <blockquote>
    <p>Procedure or function 'hrm_Langauges' expects parameter '@CreatedOn', which was not supplied.</p>
  </blockquote>