I'm trying to insert data into SQLServer from access, I've got the connection working but I'm having trouble inserting the date. I'm getting the following error message.
"The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. "
I think that this is because the dates in access are in English date format and so it is having trouble recognising that the 13/6/09 is a valid date. Can anyone help with this problem?
My insert code is as follows:
I have tried taking out the single quotes around the inspection date, but this just resulted in the date being entered as if it was 0, so in SQLServer it's all just 1/1/1900.
"The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. "
I think that this is because the dates in access are in English date format and so it is having trouble recognising that the 13/6/09 is a valid date. Can anyone help with this problem?
My insert code is as follows:
Code:
Dim rs1 As New ADODB.Recordset
rs1.Open "Select * From tblEstateInspections1", cnFrom, adOpenStatic, adLockOptimistic
While Not rs1.EOF
strInsertCommand = "Insert into dbo.tblEstateInspections (StairID, InspectionDate) " & _
" Values (" & rs1("StairID") & ", '" & rs1("InspectionDate") & "')"
cnTo.Execute (strInsertCommand)
rs1.MoveNext
Wend
I have tried taking out the single quotes around the inspection date, but this just resulted in the date being entered as if it was 0, so in SQLServer it's all just 1/1/1900.