Jump to content

LabSQL problem


Recommended Posts

Hi

I'm new to SQL and i'm facing with following error:

using "Example - Insert into a Table.vi" to add a record in Access2000 DB composed by only one table named "Section" with one numeric field named "ID".

When I run vi with following Command Text "INSERT INTO Section VALUES (1)" get this error code "-2147217900 Exception occured in Microsoft JET Database Engine. Syntax error in instruction INSERT INTO".

Now I change the name of the table from "Section" to "AAAA" (but any other name is fine) and with the same command (replacing only table name) the error disappear and the values are correctly writed!!!

Seems that "Section" is not a valid name for a table using LabSQL...or i'm missing something, i'm not experienced with SQL.

I cannot change the name of tables in DB because are used from other programs.

thanks for help

Maak

Link to comment

QUOTE (maak @ May 11 2008, 02:01 PM)

Yes, "SECTION" is a reserved word in ODBC land. http://msdn.microsoft.com/en-us/library/aa238507(SQL.80).aspx' rel='nofollow' target="_blank">Here is a good reference to all the "taboo" words that should not be used as table/field names. Note that even though Access doesn't have a problem with "Section", it is the ODBC driver that rejects it because it is reserved.

Even though these reserved keywords should not be used, they can be worked around by using brackets to surround the table name, like this for example:

"INSERT INTO [section] VALUES (1)"

or even better:

"INSERT INTO [DBName.tablename] VALUES (1)"

Hope this helps you out.

Link to comment

QUOTE (orko @ May 11 2008, 10:21 PM)

Even though these reserved keywords should not be used, they can be worked around by using brackets to surround the table name, like this for example:

Hope this helps you out.

the brackets is all what I need :thumbup:

thanks

Link to comment

QUOTE (maak @ May 12 2008, 02:29 AM)

the brackets is all what I need :thumbup:

thanks

It's good practice to always use brackets around table names and column identifiers. This will not only catch reserved words but also identifiers that have embedded spaces, which for SQL is a syntax separator otherwise.

Rolf Kalbermatter

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.