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

my code

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 :(

oh sorry guys, my bad :(

i was too careless... date seems to be a reserve words, so [date] fix the problem.

sorry again

Thanks for the info.
I assume you can close this threat.

Hi buddy!
It was good that you did not remmove this post. I found my answer here! I was wondering on how to actually insert datetime to access from VB date time picker. If you meet one person today, tell him/her that "We learn through others' mistakes".
Stay well!

thanx buddy, i also learned from your mistakes.. thanks again..

is this for microsoft visual 2010?

by the way, does anybody knows how to link the date time picker and combobox microsoft visual studio 2010 to access database? I just really dont know.

help much appreciated

kindly tell me how we update time automatically in inline database in android..?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.