Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-10-30
3
Medium Priority
?
153 Views
Last Modified: 2010-04-23
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
0
Comment
Question by:rbertke
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Expert Comment

by:MikeMCSD
ID: 12453103

Change:   conDB2.Open()

       To:   cmdKey.Open()


0
 
LVL 16

Accepted Solution

by:
MikeMCSD earned 2000 total points
ID: 12453123
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
 

Author Comment

by:rbertke
ID: 12453244
I had tried variations so much that I thought this had been tried...Obviously not as this worked...Thanks very much!  Rob
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question