Solved

SQL Query Access 2000 MDB file from delphi

Posted on 2011-03-09
6
645 Views
Last Modified: 2012-05-11
Hi Guys

i have a very strange problem querying a certain column within an access database. i can query any other table fine without issues but this one in specific is getting a pain.

my query is as follows

SELECT Scale.ScaleType, Scale.Sequence, Scale.size FROM Scale ORDER BY Scale.ScaleType

this will error on me but if i go into the mdb and double click the column name size and rename it to test. and retry my query

SELECT Scale.ScaleType, Scale.Sequence, Scale.test FROM Scale ORDER BY Scale.ScaleType

This will output the correct data without issue. i then rename it back to size and query again and it errors. unfortunatly i need to keep it as the sale column name because there is a retail system running off it and my querys are external for another purpose so the changes to the DB are easier said then done.

Scaletype = Number
Sequence = Number
Size = text
0
Comment
Question by:TG-Steve
[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
  • 3
  • 2
6 Comments
 
LVL 24

Expert Comment

by:jimyX
ID: 35082300
In SQL, as in many DBs, you can not use certain fields/columns/tables names that conflict with internal reserved words such as Size, Name, Index,...etc
But you can add additional character to be SSize or Siz.
0
 

Author Comment

by:TG-Steve
ID: 35082338
Hi Jimyx

What you state would certainly make sence and answer what has been happening. sorry i am a little lost in translation of the additional information you provided. is the additional characters to be added in the database or in the query and if so being the query could you please give me an example on how to execute this please

kind regards
steve
0
 
LVL 24

Expert Comment

by:jimyX
ID: 35082364
I mean the main name of the field in the DB.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:TG-Steve
ID: 35082462
The problem i have is that the MDB in question is used by our retail software and i cannot alter it due to support issues and the fact it will probably crash the retail system. for a few months i have been working on an application that can pull tons of information out of the MDB and export it to a website MySql DB and everything seems to be working fine. However this issue now has always been there for me since i started exporting data and for the sake of argument i just renamed the field in a copied MDB for all my testing. Now i am at the point that everything works well but i need it to pull the information from the live MDB but i dont have the option to alter the inner tables etc.
0
 
LVL 6

Accepted Solution

by:
FactorB earned 500 total points
ID: 35082766
Just use square brackets in query

SELECT [Scale].[ScaleType], [Scale].[Sequence], [Scale].[Size] FROM [Scale] ORDER BY [Scale].[ScaleType]
in this case the engine will not look for reserved words inside brackets as are SELECT, ORDER ... and probably Size

Regards,
B.
0
 

Author Closing Comment

by:TG-Steve
ID: 35082825
Life Saver
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

756 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