Solved

SQL Query Access 2000 MDB file from delphi

Posted on 2011-03-09
6
640 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now