0

I'm currently doing a project for a client. And for the database I'm using localDB and for deployment I'm using ClickOnce. My database name is Database.mdf and the connection string is

Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True

When I launch this application, it works fine on my computer. However when I install it on another computer I get the error:

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. The specified LocalDB instance does not exist.)

I have looked for answers in other forums as well however nothing seems to work. Can anyone tell me what the problem is?

Edit: I have included LocalDB and .Net Framework 4.6.1 as prerequisite.

Edit 2: The above problem was fixed but I have a new error now! It says that it cannot create the database because it is version 852 and this server supports version 706 and earlier!

Error Image

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Did you actually include LocalDB as an install prerequisite in your ClickOnce application? [See also](https://stackoverflow.com/q/45803290/4137916). – Jeroen Mostert Mar 13 '19 at 10:31
  • Yes I have included LocalDB and .Net Framework 4.6.1 as prerequisite. – Technical Noob Mar 13 '19 at 10:45
  • Run `sqllocaldb info` on the target machine. It should confirm the existence of an `MSSQLLocalDB` instance. If `sqllocaldb` won't run, then LocalDB probably didn't install at all; otherwise, the instance can be explicitly created with `sqllocaldb create` if the installer did not take care of it. (This could easily happen if, for example, the installer ran under a different account, since LocalDB instances are specific to the user unless explicitly shared.) – Jeroen Mostert Mar 13 '19 at 10:47
  • Thank You! It seems the instance in another computer was v11.0! The above problem was fixed but I have a new error now! It says that it cannot create the database because it is version 852 and this server supports version 706 and earlier! I have provided the image for it above by editing my post! Would you please take a look at that! – Technical Noob Mar 13 '19 at 11:15
  • That's because you used SQL Server 2016 to make your database, but the machine has SQL Server 2012 installed. [See also](http://sqlserverbuilds.blogspot.com/2014/01/sql-server-internal-database-versions.html). Check the link I posted originally for advice on how to include SQL Server 2016 LocalDB in the prerequisites, instead of SQL Server 2012. You could also, of course, create your own database with the 2012 version only. – Jeroen Mostert Mar 13 '19 at 11:17
  • @TechnicalNoob upgrade SQL Server Express. Local DB is a feature of SQL Server Express, it doesn't come by itself. Downgrading to 2012 isn't a great idea though. SQL Server 2016 SP1 added features to LocalDB that used to be available only on Enterprise edition, like columnstores, compression and more – Panagiotis Kanavos Mar 13 '19 at 11:17
  • OMG It Worked! It seems I was using LocalDB 2017 version to make the database and I was installing LocalDB 2012 in my clients computer! Thats why the instance name of LocalDB was MSSQLLocalDB in my computer and v11.0 in my clients computer. So I installed LocalDB 2017 in my clients computer and it worked! I love you man! Thank you! – Technical Noob Mar 13 '19 at 11:30

1 Answers1

1

Check whether you able to connect with this localDB string in the SQL Management Studio. If you unable to connect with this. then this connection string is not valid

check your connection string here: Unable to connect to localDB in VS2012 – "A network-related or instance-specific error occurred while establishing a connection to SQL Server..."