Refreshing a Query that accesses a database with a "-" in its name
Posted: 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 "-".
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.
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;
Currently I don't even have a viable workaround as i can't remove the default database and the sql-text is dynamically created.