Bonjour

Je voudrais faire un insert dans une de mes tables dont un champs est de type DateTime.

La valeur provient d'un MasktextBox.

Voici mon insert :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
36
37
38
 
 
strSql = "INSERT INTO freight_rate " + _
"( " + _
"rate_PKID, " + _
"company_code, " + _
"division, " + _
"vendor_number, " + _
"location_code_from, " + _
"location_code_to, " + _
"rate_type, " + _
"charge_category_code, " + _
"rate, " + _
"rate_basis_unit, " + _
"currency_code, " + _
"date_effective_from, " + _
"date_effective_to " + _
") " + _
"VALUES " + _
"( " + _
"" & intNextValue & "," + _
"'" & Me.cboCompany.Text & "'," + _
"'" & Me.cboDivision.Text & "'," + _
"'" & Me.cboCarrier.Text & "'," + _
"'" & Me.cboFromWarehouse.Text & "'," + _
"'" & Me.cboDestinationZone.Text & "'," + _
"'" & Me.cboRateType.Text & "'," + _
"'" & Me.cboChargeCategory.Text & "'," + _
"" & Me.txtRate.Text & "," + _
"'" & Me.cboRateBasisUnit.Text & "'," + _
"'" & Me.cboCurrency.Text & "'," + _
" ' " & Convert.ToDateTime(Me.mskEffectiveFromDate.Text).ToString.Substring(0, 10) & " '," + _
"'" & Convert.ToDateTime(Me.mskEffectiveToDate.Text).ToString.Substring(0, 10) & "'" + _
")"
 
sqlCommandCrps = sqlConnectionCrps.CreateCommand
sqlCommandCrps.CommandText = strSql
sqlCommandCrps.ExecuteNonQuery()
Si je met mon convert.toDateTime... entre ' ' j'obtiens ce message d'erreur
The conversion ofchar data type to smalldatetime data type result in a out of range smalldatetime value.

si je ne les met pas la date que je trouve à insérer est 01/01/1900

Es-ce que quelqu'un sait pourquoi ?

Merci beaucoup