title: "Out-of-range value" error when converting a varchar to datetime
body: <p>I have this code </p>
  
  <pre><code>datecreation = todaydate.Substring(6, 4) + todaydate.Substring(3, 2) + 
                     todaydate.Substring(0, 2) 
  
  string sql = "insert into Usertable ";
  sql += "values(" + mVendid + ", '" + usrname + "','" + usrpass + "', cast('" + 
  datecreation + "'as DATETIME),'" + createdby + "')";
  </code></pre>
  
  <p>The problem is whenever it is running in server it is giving error. In Local host or in SQL server management it is working fine. </p>
  
  <p>What the heck is it not working whenever it is in the web</p>
  
  <blockquote>
    <p>The error is The conversion of a varchar data type to a datetime data
    type resulted in an out-of-range value. The statement has been
    terminated.</p>
  </blockquote>