Convert datetime to smalldatetime in sql insert query
<p>I have an INSERT query like this</p>

<pre><code>INSERT INTO tna_temp_attendance VALUES('" + strEmpCode + "', CONVERT(SMALLDATETIME, '" + dtDateTime.ToString() + "'), 0, " + _inOutMode.ToString() + ", null, 0, 'CHO-', '" + strMachine + "')
</code></pre>

<p>When I execute this query there is this error occurred
"<strong>the conversion of a varchar data type to a datetime data type resulted in an out-of-range value</strong>"</p>

<p>Help Plz</p>

<p>My database has this table "<strong>tna_temp_attendance</strong>"
and its columns are</p>

<ul>
<li>Emp_id    <strong>char(6)</strong>  </li>
<li>Wdate     <strong>smalldatetime</strong>  </li>
<li>Is_read   <strong>bit</strong>  </li>
<li>Machine_Status    <strong>bit</strong>  </li>
<li>Process_Status    <strong>bit</strong>  </li>
<li>Is_Error  <strong>bit</strong>   </li>
<li>Loc_no    <strong>char(4)</strong>  </li>
<li>Ip    <strong>varchar(16)</strong></li>
</ul>

<p>Edit</p>

<p>I passed the date like this also</p>

<p><strong>CONVERT</strong>(<strong>SMALLDATETIME</strong>, '" + Convert.ToDateTime(dtDateTime.ToString("yyyy-MM-dd hh:mm:ss")) + "')</p>

<p>But it also not working</p>