简体   繁体   中英

SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified on LocalDB

I have written ac# wpf application that talks to a SQL Server 2012 LocalDB on my machine.

To make the app accessible on other peoples machine's I have:

  • Included the database file in a zip for the user to extract to the programs directory.
  • Written SQL scripts to attach the database to the local machine's LocalDB instance.

The application works perfectly fine on my machine, however after installing on someone else's computer (after the .NET and SQL Server 2012 LocalDB prerequisites have been installed), it keeps filling up the error logs with the following message:

Exception: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified).

Now there are a lot of other references to the same error message, but I cannot find any that relate to LocalDB or what to try with LocalDB.

Keeping in mind the application is designed for the common 'end-user', so I can't have them following numerous instructions to use SQL Server Management Studio or configuration manager.

The attach SQL script is as follows in case you need to know:

CREATE DATABASE BaseDB
    ON (FILENAME = 'C:\MyApp\Base\MyDB.mdf'), 
(FILENAME = 'C:\MyApp\Base\MyDB.ldf')
FOR ATTACH; 

Can anyone suggest why this wouldn't be working?

To solve this problem:

  1. Install this update to Microsoft Net Framework 4.0: KB2544514
  2. Start: `SqlLocalDB [create|c] instance-name [-s]`
    For example: `SqlLocalDB.exe create MSSQLLocalDB -s`

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM