The Bitman The Bitman -4 years ago 172
SQL Question

TADOCommand.execute

When I execute this SQL query:

aC.commandText := 'SELECT [MODEL], [PART], [SECTION], [FOOTPRINT], [NODELIST] FROM BJT';
aDS.resultSet := aC.execute;


it runs successfully. But when I run this one (with a where clause):

aC.commandText := 'SELECT [MODEL], [PART], [SECTION], [FOOTPRINT], [NODELIST] FROM BJT WHERE lower( BJT.MODEL ) LIKE ''m%'';';
aDS.resultSet := aC.execute;


It throws an exception with message : 'Unspecified exception'.
I tried it with '*' instead of '%', with/without [] around then MODEL/BJT.MODEL in the where clause, it was the same. What is wrong with it? The brackets are necessaries because it is generated by program for any field names (handling reserved words like SECTION)

Answer Source

Try with proper Access syntax:

'SELECT [MODEL], [PART], [SECTION], [FOOTPRINT], [NODELIST] FROM BJT WHERE LCase([MODEL]) LIKE ''m*'';'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download