Error in MSQuery.QuoteName=True with Master Detail setup

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
siatc1
Posts: 8
Joined: Fri 13 Jan 2006 05:58

Error in MSQuery.QuoteName=True with Master Detail setup

Post by siatc1 » Tue 05 Dec 2006 03:19

I have set the following in MSQuery.

1. MSQuery.Options.QuoteName=True
2. MSQuery.Options.QueryRecName=True
3. MSQuery.MasterFields='Title_id'. Note that I'm using Pubs db in MSSQL
4. MSQuery.DetailFields='D.Title_id'
5. MSQuery.SQL='Select * from titleauthor A join titles D on A.title_ID=D.title_ID'

When MSQuery open, it hit error "invalid column D.Title_id". When I check with SQL Profiler, it generate the following statement:

exec sp_executesql N'SELECT * FROM titleauthor A JOIN titles D on A.title_ID=D.title_ID
WHERE [D.title_id] = @P1 ', N'@P1 varchar(6)', 'PS3333'


I believe the correct statement should be :
exec sp_executesql N'SELECT * FROM titleauthor A JOIN titles D on A.title_ID=D.title_ID
WHERE D.[title_id] = @P1 ', N'@P1 varchar(6)', 'PS3333'

Thanks.

Sia

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Tue 05 Dec 2006 13:32

The TCustomDADataSet.Options.QuoteNames property doesn't support field names with table aliases.
Do not use a table alias in the field name or do not use the TCustomDADataSet.Options.QuoteNames = True mode.

Post Reply