0

I've developed a wpf app with connection string to sql server 2014 database database works fine with windows 10 with sql server 2016 and but doesn't work with windows 7 with sql server 2014!

connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string="Server=(localdb)\mssqllocaldb;Database=LearningSystem;attachdbfilename=|DataDirectory|Parking.mdf;integrated security=True;Connect Timeout=30;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
M.B
  • 23
  • 4
  • 2
    Possible duplicate of [How to install localdb separately?](https://stackoverflow.com/questions/23320013/how-to-install-localdb-separately) – Dour High Arch Jul 22 '19 at 17:45
  • Please tell us what error messages you're getting so we aren't guessing what the issue might be. "It doesn't work" is not useful information. –  Jul 22 '19 at 17:51
  • On windows 7 with sql server 2014 throws an exception massage: "The underlying provider failed on Open" – M.B Jul 22 '19 at 18:37

1 Answers1

0

You are using a localdb created on your Windows 10 machine. You have to either copy database on Windows 7 machine or create another one there.

Server=(localdb)\mssqllocaldb

attachdbfilename=|DataDirectory|Parking.mdf

Gaurav Mathur
  • 804
  • 5
  • 14
  • I've copied the database file. It exists in application's bin folder – M.B Jul 22 '19 at 17:41
  • You have to explicitly set `|DataDirectory|` using `CurrentDomain.SetData` or you can provide full path to test if your app is able to find db. Like `attachdbfilename=c:\projectname/bin/Parking.mdf`, replace path with your actual db path – Gaurav Mathur Jul 22 '19 at 17:48
  • LocalDB is a separate application; it has to be on the Win7 machine or he has to install it when he installs the WPF app. You should also never open with Write access a file in your Program Files folder; if he needs Write access he needs to copy the DB file to a place he has such access. – Dour High Arch Jul 22 '19 at 18:39