通过 FireDac (Delphi) 连接到 MS SQL LocalDB 时出错
Error connecting to MS SQL LocalDB through FireDac (Delphi)
连接参数:
Server=(LocalDb)\MSSQLLocalDB
DriverID=MSSQL
ODBCAdvanced=AttachDbFileName=C:\Dir\Dir\TestDB.mdf
连接成功。
像 FDConnection.ExecSQLScalar('SELECT ....') 这样的请求 - 效果很好
通过 TFDScript 请求 - 工作正常
但 运行 TFDQuery 生成以下错误:
[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.
只需将 Database=any_name 添加到连接字符串。
Server=(LocalDb)\MSSQLLocalDB
DriverID=MSSQL
ODBCAdvanced=AttachDbFileName=C:\Dir\Dir\TestDB.mdf
Database=MyDatabase
连接参数:
Server=(LocalDb)\MSSQLLocalDB
DriverID=MSSQL
ODBCAdvanced=AttachDbFileName=C:\Dir\Dir\TestDB.mdf
连接成功。
像 FDConnection.ExecSQLScalar('SELECT ....') 这样的请求 - 效果很好 通过 TFDScript 请求 - 工作正常
但 运行 TFDQuery 生成以下错误:
[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.
只需将 Database=any_name 添加到连接字符串。
Server=(LocalDb)\MSSQLLocalDB
DriverID=MSSQL
ODBCAdvanced=AttachDbFileName=C:\Dir\Dir\TestDB.mdf
Database=MyDatabase