How to use .Locate when column name is a keyword
Using XE5 and ADO, how can I use TADOQuery.Locate
when the column name is a keyword?
For example, we have a table with a column named Desc
which is a keyword.
The code below generates a runtime error (exception class EOleException
with message Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another
):
ADOQueryQP1.Locate('Desc', 'FindMe', [])
I've tried [] and double quotes around Desc
.
With [Desc]
or "Desc"
(single or double quotes) we get an exception class EDatabaseError
with a message ADOQueryQP1: Field '[Desc]' not found
.
A related question from someone in 2012: Selecting a column whose name is a SQL reserved keyword
source to share