probleme conversion datetime
Bonjour,
Je suis bloqué à cause d'une conversion que la base ne prend pas en compte. En effet, j'utilise un DataReader :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
Dim sql_search As String = "SELECT dateheuretogo, dateheuretoend"
Dim cmdsearch As SqlCommand = New SqlCommand(sql_search, cnn)
cnn.Open()
Dim cmdRead As SqlDataReader = cmdsearch.ExecuteReader
cmdRead.Read()
Dim dateheuredepart as datetime= cmdRead("dateheuretogo")
Dim dateheureretour as datetime = cmdRead("dateheuretoend")
If cmdRead.HasRows Then
While cmdRead.Read
If 1=2 Then
...
...
End If
End While
End If
cmdRead.Close()
cnn.Close()
cnn.Open()
'écriture dans la base
Dim sqlwritetodatabase As String = "INSERT INTO tbl_heure(dateheuretogo, dateheuretoend" & _
"VALUES('" & dateheuretogo & "','" & dateheuretoend & "')"
Dim cmdwritetodatabase As SqlCommand = New SqlCommand(sqlwritetodatabase, cnn)
cmdwritetodatabase.ExecuteNonQuery() |
Voilà le code, le problème ce situe au moment de l'écriture dans la base, j'ai le message d'erreur suivant :
Citation:
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. The statement has been terminated.
Que doit-je faire? Mercii d'avance.