How to insert time into access database (VB Net)
<p>I try to insert a Date value into MS Access database through VB Net but I get the "can't convert xxxxx to timespan" error. I tried this:</p>

<pre><code>ComandoBD.Parameters.Add("@Hora", OleDbType.DBTime).Value = TimeOfDay.ToString("HH:mm:ss")

ComandoBD.Parameters.Add("@Hora", OleDbType.DBTime).Value = TimeOfDay

ComandoBD.Parameters.Add("@Hora", OleDbType.DBTime).Value = time.TimeOfDay
</code></pre>

<p>But nothing, In the Access database the time field is set to "Date/Time" because there is no option for Time only.</p>

<p>This is the entire snippet of that section:</p>

<pre><code>For i As Integer = 0 To Form2.DataGridView2.Rows.Count - 2
            Try
                ConexionBD.Open()
                ComandoBD.Connection = ConexionBD
                ComandoBD.CommandText = "INSERT INTO Ventas (IdProducto, Fecha, Hora) VALUES (@IdProducto, @Fecha, @Hora)"
                ComandoBD.Parameters.Add("@IdProducto", OleDbType.VarChar).Value = Form2.DataGridView2.Rows(i).Cells(0).Value
                ComandoBD.Parameters.Add("@Fecha", OleDbType.DBDate).Value = Now

                ComandoBD.Parameters.Add("@Hora", OleDbType.DBTime).Value = time.TimeOfDay

                ComandoBD.ExecuteNonQuery()
                ComandoBD.Dispose()
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
            ConexionBD.Close()
        Next
</code></pre>

<p>When I do it (for other fields) with OleDbType.VarChar, OleDbType.Boolean or even OleDbType.Binary I don´t have any problem.</p>

<p>Please help.</p>

<p>Thanks.</p>