Wolfert
05-22-2003, 01:44 AM
Hello,
I use a VB form (datagrid) to enter data in a SQL table. When I insert the record, the following error occurs:
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting datetime from character string.
The field in the SQL table is defined as datetime.
This is how I update the SQL table:
Private Sub UpdateRecordset()
'Update recordset with MsFlexgrid
Dim SQLString As String
Dim rij As Integer
'First delete all data
SQLString = "Delete From [Orders - sub verkoop] WHERE OrderID = " & frmInterneOrders.LblOrdernummer
MyConnection.Execute SQLString
'Add data
For rij = 1 To MsFlexgrid1.Rows - 2
SQLString = "INSERT INTO [Orders - sub verkoop] (OrderID, Volgnummer, Gereed, [Datum bij klant], Aantal, opmerking ) " _
& "SELECT " & frmInterneOrders.LblOrdernummer & " AS ORDNR, " _
& MsFlexgrid1.TextMatrix(rij, 0) & " AS VOLG, " _
& "'#" & Format(MsFlexgrid1.TextMatrix(rij, 1), "dd/MM/yyyy") & "#' AS GER, " _
& "'#" & Format(MsFlexgrid1.TextMatrix(rij, 2), "dd/MM/yyyy") & "#' AS DATKLANT, " _
& MsFlexgrid1.TextMatrix(rij, 3) & " AS QNTY, " _
& "'" & MsFlexgrid1.TextMatrix(rij, 4) & "' AS OPM"
MyConnection.Execute SQLString 'Do it
Next rij
End Sub
Patrick.
I use a VB form (datagrid) to enter data in a SQL table. When I insert the record, the following error occurs:
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting datetime from character string.
The field in the SQL table is defined as datetime.
This is how I update the SQL table:
Private Sub UpdateRecordset()
'Update recordset with MsFlexgrid
Dim SQLString As String
Dim rij As Integer
'First delete all data
SQLString = "Delete From [Orders - sub verkoop] WHERE OrderID = " & frmInterneOrders.LblOrdernummer
MyConnection.Execute SQLString
'Add data
For rij = 1 To MsFlexgrid1.Rows - 2
SQLString = "INSERT INTO [Orders - sub verkoop] (OrderID, Volgnummer, Gereed, [Datum bij klant], Aantal, opmerking ) " _
& "SELECT " & frmInterneOrders.LblOrdernummer & " AS ORDNR, " _
& MsFlexgrid1.TextMatrix(rij, 0) & " AS VOLG, " _
& "'#" & Format(MsFlexgrid1.TextMatrix(rij, 1), "dd/MM/yyyy") & "#' AS GER, " _
& "'#" & Format(MsFlexgrid1.TextMatrix(rij, 2), "dd/MM/yyyy") & "#' AS DATKLANT, " _
& MsFlexgrid1.TextMatrix(rij, 3) & " AS QNTY, " _
& "'" & MsFlexgrid1.TextMatrix(rij, 4) & "' AS OPM"
MyConnection.Execute SQLString 'Do it
Next rij
End Sub
Patrick.