daisy25
02-14-2005, 10:08 AM
Hi all, when executing this code:
Dim saleCommand As New SqlCommand("INSERT INTO SalesDetails ([Date], [Time], [OperatorID], [CustomerID], [PaymentID]) VALUES ('" & Format(Now(), "dd/MM/yyyy") & "', '" & Format(Now(), "HH:mm") & "', '1', '1', '1');", myConnection)
I get a data type conversion error saying the conversion from string to datetime caused an out-of-range data value. But when I execute this code:
Dim saleCommand As New SqlCommand("INSERT INTO SalesDetails ([Date], [Time], [OperatorID], [CustomerID], [PaymentID]) VALUES ("#& Format(Now(), "dd/MM/yyyy") & "#, #" & Format(Now(), "HH:mm") & "#, '1', '1', '1');", myConnection)
I get an error saying "The name '#14' is not permitted in this context".
Any ideas?
Dim saleCommand As New SqlCommand("INSERT INTO SalesDetails ([Date], [Time], [OperatorID], [CustomerID], [PaymentID]) VALUES ('" & Format(Now(), "dd/MM/yyyy") & "', '" & Format(Now(), "HH:mm") & "', '1', '1', '1');", myConnection)
I get a data type conversion error saying the conversion from string to datetime caused an out-of-range data value. But when I execute this code:
Dim saleCommand As New SqlCommand("INSERT INTO SalesDetails ([Date], [Time], [OperatorID], [CustomerID], [PaymentID]) VALUES ("#& Format(Now(), "dd/MM/yyyy") & "#, #" & Format(Now(), "HH:mm") & "#, '1', '1', '1');", myConnection)
I get an error saying "The name '#14' is not permitted in this context".
Any ideas?