title: Saving date in yyyy-MM-dd format into SQL Server 2008 if I passed date in dd-MM-yyyy format
body: <p>I am trying to save date into a SQL Server 2008 database. I have converted date in <code>dd/MM/yyyy</code> format even though the date stored in database as <code>yyyy-MM-dd</code> format. My button click code:</p>
  
  <pre><code>protected void Submit_Click(object sender, EventArgs e)
  {
      DateTime fdate = DateTime.ParseExact(txtDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
      sample = fdate;
  }
  
  public class sample
  {
      public string sample(DateTime fdate)
      {
         string qry = "insert into sample values('"+fdate+"')";
         SqlDataReader dr = conn.query(qry);
      }
  }
  </code></pre>
  
  <p>Database date(column) datatype is <code>date</code>. May I know the reason??<br>
  My other classes</p>
  
  <pre><code>  public class Connection
  {
      SqlConnection conn;
      SqlCommand cmd;
      public SqlDataAdapter ad;
      public DataTable dt = new DataTable();
  
      public void connclose()
      {
          conn.Close();
      }
      public Connection()
      {
  
          conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
          cmd = null;
      }
    //------------------ connection string---------------------------------------------------------
    ---------------------//
      public string nonquery(string qry)
      {
          string str;
          if (conn.State == ConnectionState.Open)
          {
              conn.Close();
          }
  
              conn.Open();
  
          cmd=new SqlCommand(qry, conn);
          str=cmd.ExecuteNonQuery().ToString();
          conn.Close();
          return str;
  
      }
  
      public SqlDataReader query(string qry)
      {
          if (conn.State == ConnectionState.Open)
          {
              conn.Close();
          }
  
          conn.Open();
  
          cmd = new SqlCommand(qry, conn);
          SqlDataReader dr = cmd.ExecuteReader();
          return dr;
      }
  </code></pre>