Syntax error on 'INSERT INTO' statement when trying to add to access database

Sorry if this should be in the DB area, but not sure if the problem is the DB or the VB code.  

The following code does not work (I get a syntax error in INSERT INTO message).  The database QSSupport.mdb is in the correct path with a table called 'tblKey'.  That table has only one field called 'KeyCode2'.  That field is a text field (50 characters), is not indexed, duplicates and zero length strings are allowed.  Can anyone tell me why this is not working?:

Public Sub Update
        Dim conDB2 As New OleDb.OleDbConnection
        Dim cmdKey As New OleDb.OleDbCommand
        Dim myDS As New DataSet

        conDB2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\QSSupport.mdb"

        cmdKey.CommandText = "INSERT INTO tblKey [keycode2] VALUES '7'"
        cmdKey.Connection = conDB2
        conDB2.Open()
        cmdKey.ExecuteNonQuery()
End Sub
rbertkeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MikeMCSDCommented:

Change:   conDB2.Open()

       To:   cmdKey.Open()


0
MikeMCSDCommented:
forget that last post, I was wrong.

Try this:

"INSERT INTO tblKey [keycode2] VALUES '7'"

Change to:

"INSERT INTO tblKey (keycode2) VALUES ('7')"

I added (  ) in 2 places


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rbertkeAuthor Commented:
I had tried variations so much that I thought this had been tried...Obviously not as this worked...Thanks very much!  Rob
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.