title: To insert datepicker date to sql server
body: <p>I want to insert a date from datepicker to sql server.The table is as below :</p>
  
  <pre><code>Create table testDate
  (
  EventStart date,
  EventEnd date
  )
  
  Create proc sptestdate
  @EventStart date,
  @EventEnd date
  as
  begin
  Insert into testDate(EventStart,EventEnd) values(@EventStart,@EventEnd)
  end
  </code></pre>
  
  <p>and the datepicker is as below :</p>
  
  <pre><code> &lt;script&gt;
      $(function () {
          $(".datepicker").datepicker({
              dateFormat: "dd/mm/yy"
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>I do this using the below code-behind:</p>
  
  <pre><code>    protected void Button1_Click(object sender, EventArgs e)
  {
      string CS = ConfigurationManager.ConnectionStrings["ss"].ConnectionString;
      using (SqlConnection con = new SqlConnection(CS))
      {
          con.Open();
          SqlCommand cmd = new SqlCommand("sptestdate", con);
          cmd.CommandType = CommandType.StoredProcedure;
          cmd.Parameters.AddWithValue("@EventStart", SqlDbType.DateTime).Value = txtEventStart.Value;
          cmd.Parameters.AddWithValue("@EventEnd", SqlDbType.DateTime).Value = txtEventEnd.Value;
          cmd.ExecuteNonQuery();
      }
  }
  </code></pre>
  
  <p>However, it throws an error</p>
  
  <pre><code>  "Error converting data type nvarchar to date."
  </code></pre>