i can't get DateTimePicker to insert into Access databse. I've tried all the suggestion i can find from this forum, so i'm thinking my problem is different?
my table has a column date which has a Date/Time format
Dim cmd As OleDbCommand Dim sqlstr As String, ans As Boolean Dim mydate As DateTime mydate = Me.dtPickerT.Value sqlstr = "INSERT INTO table(date) VALUES (" & mydate & ")" cmd = New OleDbCommand(sqlstr, con) ans = cmd.ExecuteNonQuery() If (ans = True) Then 'message added MsgBox("success") Else MsgBox("not entered") '' error End If cmd = Nothing
error message is: Syntax error in INSERT INTO statement. - Micorsoft Office Access Database Engine
the query returned by cmd is: INSERT INTO taken(date) VALUES (1/8/2012)
what did i do wrong?? Pls help :D
i'v even tried (#" & mydate & "#) and (" & dtPickerT.Value.ToString & ") etc :(