Page 1 of 1

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

Posted: Fri 01 Jul 2016 13:49
by Deeem2031
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.

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

Posted: Mon 04 Jul 2016 13:04
by ViktorV
Thank you for the information. We have reproduced the problem and investigation is in progress. We will inform you when we have any results.

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

Posted: Tue 05 Jul 2016 09:19
by Deeem2031
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.

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

Posted: Thu 07 Jul 2016 08:38
by ViktorV
We have already fixed this issue, the fix will be included in the next SDAC build.