title: how to solve Conversion failed when converting date and/or time from character string?
body: <blockquote>
    <p>Conversion failed when converting date and/or time from character
    string</p>
  </blockquote>
  
  <p>I am new in Asp.net. i want to upload image and save records in Sql Database it caught  "Conversion failed when converting date and/or time from character string". I don't know why this error encountered during runtime. Anyone know help me . its very helpful my project</p>
  
  <pre><code> protected void Add_Click(object sender, EventArgs e)
              {
                  if (!FileUpload1.HasFile)
                  {
                      Label2.Visible = true;
                      Label2.Text = "Please Select Image File";    //checking if file uploader has no file selected
  
  
                  }
                  else
                  {
                      int length = FileUpload1.PostedFile.ContentLength;
                      byte[] pic = new byte[length];
  
  
                      FileUpload1.PostedFile.InputStream.Read(pic, 0, length);
                      string constr = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
                      SqlConnection con = new SqlConnection(constr);
                      SqlCommand cmd1 = new SqlCommand("insert into Student" + "(RegNo,Name,DOB,Gender,Address,Country,CreatedTime,Picture) values(@RegNo,@Name,@DOB,@Gender,@Address,@Country,@date,@photo)", con);
                      con.Open();
                      cmd1.Parameters.AddWithValue("@RegNo", RegNo.Text);
                      cmd1.Parameters.AddWithValue("@Name", Name.Text);
                      cmd1.Parameters.AddWithValue("@DOB", Dob.Text);
                      cmd1.Parameters.AddWithValue("@gender", Gender.SelectedValue);
                      cmd1.Parameters.AddWithValue("@Address", Address.Text);
                      cmd1.Parameters.AddWithValue("@Country", Country.Text);
                      cmd1.Parameters.AddWithValue("@date", DateTime.Now);
                      cmd1.Parameters.AddWithValue("@photo", pic);
  
                      try
                      {
                          cmd1.ExecuteNonQuery();
                          Label2.Visible = true;
                          Label2.Text = "Image Uploaded Sucessfully";
                          con.Close();//after Sucessfully uploaded image
                      }
                      catch
                      {
                      }
                  }
  
  
                  Response.Redirect("~/WebForm1.aspx");
              }
  </code></pre>