使用XE5和ADO,当列名是关键词时,如何使用TADOQuery.Locate
?
例如,我们有一个包含名为Desc
的列的表,它是一个关键字。
以下代码生成运行时错误(异常类EOleException
,消息为Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another
):
ADOQueryQP1.Locate('Desc', 'FindMe', [])
我在[{1}}周围试过了[]和双引号。
使用Desc
或[Desc]
(单引号或双引号),我们会收到包含消息"Desc"
的异常类EDatabaseError
。
2012年其他人的相关问题:Selecting a column whose name is a reserved SQL keyword
答案 0 :(得分:1)
查看以下解决方法是否可以接受:
Provider
属性设置为'SQLOLEDB'
和CursorLocation
属性设置为clUseServer
。