Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL Query Access 2000 MDB file from delphi

Posted on 2011-03-09
6
Medium Priority
?
654 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
  • 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 2000 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

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!

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

885 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