Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a project that contains SQL localDB(v11.0).When I run on m PC it runs perfectly, but when I run it on other pc I get this error. I am Using Visual Studio 2013

--------------------------------------------------------------
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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.
--------------------------------------------------------------

My connection String in App.config file is
-----------------------------------------------------
connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\EMSDB.mdf;Integrated Security=True"
------------------------------------------------------------------------------
Posted
Updated 17-Feb-15 5:20am
v2
Comments
John C Rayan 17-Feb-15 10:57am    
Can you share more information with us like some code and the configuration details
A94 17-Feb-15 11:18am    
Ok I improve my question
Richard Deeming 17-Feb-15 11:32am    
Is LocalDB installed on the other PC? If not, download SqlLocalDB.msi from Microsoft[^] and install it.
A94 17-Feb-15 11:36am    
But when deploying the application the database will also get installed (ie "EMSDB.mdf") and other related files that is required to run it. So, is SqlLocalDB required on other PC ?
Richard Deeming 17-Feb-15 11:53am    
Yes, you have to install LocalDB on the computer, either using the standalone MSI file, or as part of SQL Express.
SQL Server 2012 Express LocalDB[^

"LocalDB" means "on this computer" - so if you have moved your code to a different PC, then you need to change the connection string to refer to the computer with the production SQL server instance installed on it.

This should not be the computer you develop software on - never, ever test code against production databases, unless you really like looking for new jobs quickly - and you shouldn't automatically install SQL server on every PC with your software.
 
Share this answer
 
Comments
A94 17-Feb-15 11:48am    
But how to change the connection string to refer to the computer with the production SQL server instance installed on it since different pc have different version of SQL server installed.
You need to update your connection string to match whatever is installed on that server or change it to point back to your computer that does have SQL installed on it.
 
Share this answer
 
Comments
A94 17-Feb-15 11:50am    
Ok. but how to change the connection string that matches that version of SQL server. Also it is a standalone desktop application (ie my project)
ZurdoDev 17-Feb-15 11:53am    
Is SQL installed on the PC that is getting the error?
A94 18-Feb-15 5:13am    
no.
ZurdoDev 18-Feb-15 7:27am    
Then the connection string needs to point to the server where SQL is installed. Or you have to install SQL on the machine.
You need to install LocalDB on the computer which will be using it; you can't simply copy the files to the computer and run the application.

The primary method of installing LocalDB is by using the SqlLocalDB.msi program. LocalDB is an option when installing any SKU of SQL Server 2012 Express. Select LocalDB on the Feature Selection page during installation of SQL Server Express. There can be only one installation of the LocalDB binary files for each major SQL Server Database Engine version. Multiple Database Engine processes can be started and will all use the same binaries. An instance of the SQL Server Database Engine started as the LocalDB has the same limitations as SQL Server Express

Download the SQLLocalDB.msi file from the SQL Express download page[^] and install it on the target computer.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900