Solved

SQL Query Access 2000 MDB file from delphi

Posted on 2011-03-09
6
646 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
unknown computers in my LAN 12 100
managing events in  the webrowser control 14 66
Intermittent OleDbConnection Error 20 53
Close gap between sub forms on a main form 5 28
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
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…
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

734 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