Search code examples
delphilocaldbfiredac

Error connecting to MS SQL LocalDB through FireDac (Delphi)


Connection parameters:

Server=(LocalDb)\MSSQLLocalDB
DriverID=MSSQL
ODBCAdvanced=AttachDbFileName=C:\Dir\Dir\TestDB.mdf

connect is successful.

Requests like FDConnection.ExecSQLScalar('SELECT ....') - work well Requets through TFDScript - work well

but running TFDQuery generates the following error:

[FireDAC][Phys][ODBC][Microsoft][SQL Server Native Client 11.0][SQL Server]Could not find server 'C:\Dir\Dir\TestDB' in sys.servers.
Verify that the correct server name was specified. 
If necessary, execute the stored procedure sp_addlinkedserver to add the server to sys.servers.

Solution

  • Just add Database=any_name to connection string.

    Server=(LocalDb)\MSSQLLocalDB
    DriverID=MSSQL
    ODBCAdvanced=AttachDbFileName=C:\Dir\Dir\TestDB.mdf
    Database=MyDatabase