TMSTable.Tablename := '[Database]'

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jmuehlenhoff
Posts: 36
Joined: Fri 30 Apr 2010 11:25

TMSTable.Tablename := '[Database]'

Post by jmuehlenhoff » Thu 04 Jul 2013 08:37

Hi,

we've got a database that contains a table named '[dbo].[Database]'. I can query the table just fine, but the TMSTable component is unable to open this table.

SQL Server complains about incorrect syntax.

We're using SDAC 6.6.12

This is the table CREATE statement:

Code: Select all

CREATE TABLE [dbo].[Database] (
    [Database_ID] UNIQUEIDENTIFIER CONSTRAINT [DEF_Database_Database_ID] DEFAULT newid() NOT NULL,
    [Name] NVARCHAR(40) COLLATE Latin1_General_CI_AS NOT NULL,
    [Info] NVARCHAR(max) COLLATE Latin1_General_CI_AS,
    [ArchiveMode] INTEGER CONSTRAINT [DEF_Database_ArchiveMode] DEFAULT 0 NOT NULL,
    CONSTRAINT [PK_Database] PRIMARY KEY NONCLUSTERED ([Database_ID])
)
GO

CREATE UNIQUE CLUSTERED INDEX [IDX_Database_1] ON [dbo].[Database] ([Name] ASC)
GO
Edit:

In addition the TMSQuery component is able to open the table with 'SELECT * FROM [dbo].[Database]', but calling `Append` causes the same error message.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: TMSTable.Tablename := '[Database]'

Post by AlexP » Thu 04 Jul 2013 09:40

Hello,

Since "Database" is a reserved word, you should enable the QuoteName option in both MSTable and MSQuery for correct work with such names:

MSQuery1.Options.QuoteNames := True;
MSTable1.Options.QuoteNames := True;

jmuehlenhoff
Posts: 36
Joined: Fri 30 Apr 2010 11:25

Re: TMSTable.Tablename := '[Database]'

Post by jmuehlenhoff » Thu 04 Jul 2013 09:43

Thanks,

is there any disadvantage when enabling this option?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: TMSTable.Tablename := '[Database]'

Post by AlexP » Thu 04 Jul 2013 11:04

Hello,

This option is designed for quoting names when automatically generating queries, there are no problems when using this option.

Post Reply