Refreshing a Query that accesses a database with a "-" in its name

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Deeem2031
Posts: 6
Joined: Wed 08 Jun 2016 13:45

Refreshing a Query that accesses a database with a "-" in its name

Post by Deeem2031 » Fri 01 Jul 2016 13:49

I get the error "Incorrect syntax near '.'." when trying to refresh a query that access a table inside the default database of the connection if the database contains a "-".

Code: Select all

qu := TMSQuery.Create(nil);
try
  qu.Connection := TMSConnection.Create(qu);
  qu.Connection.Server := '...';
  qu.Connection.Username := '...';
  qu.Connection.Password := '...';
  qu.Connection.Database := 'DATABASE-2016';
  qu.SQL.Text := 'SELECT * FROM [DATABASE-2016].DBO.[TABLE]';
  qu.Open;
  qu.RefreshRecord;
finally
  qu.Free;
end;
For some reason the TMSSQLRecordSet.FillTablesAliases sets the TableAlias to "[DATABASE-2016].DBO.[TABLE]" and the TableName to "TABLE" which seemingly causes the error.
Currently I don't even have a viable workaround as i can't remove the default database and the sql-text is dynamically created.

ViktorV
Devart Team
Posts: 2299
Joined: Wed 30 Jul 2014 07:16

Re: Refreshing a Query that accesses a database with a "-" in its name

Post by ViktorV » Mon 04 Jul 2016 13:04

Thank you for the information. We have reproduced the problem and investigation is in progress. We will inform you when we have any results.

Deeem2031
Posts: 6
Joined: Wed 08 Jun 2016 13:45

Re: Refreshing a Query that accesses a database with a "-" in its name

Post by Deeem2031 » Tue 05 Jul 2016 09:19

Thanks, in the meantime i was able to bypass the problem by adding "and not SameText(CatalogName, MSSQLInfo.QuoteIfNeed(DefaultCatalogName))" to the first line of MSClasses.GenerateTableName.
Nevertheless a fix would be appreciated.

ViktorV
Devart Team
Posts: 2299
Joined: Wed 30 Jul 2014 07:16

Re: Refreshing a Query that accesses a database with a "-" in its name

Post by ViktorV » Thu 07 Jul 2016 08:38

We have already fixed this issue, the fix will be included in the next SDAC build.

Post Reply