0

I build a simple CRUD app in C# and used server based database file (.mdf) in my Project. My connection string is like this:

public string connectionString { get; set; } = $"Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=\"{AppDomain.CurrentDomain.BaseDirectory}Passwords.mdf\";Integrated Security=True";

In my computer application works fine just I want, but after send to my friend, he got error that can't connect or find SQL database. Error text is:

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

So we download SQL server express 2019 for him (I use 2017 by the way) and after that, still he get the same error. I dont understand what is the problem. Any succession?

jarlh
  • 42,561
  • 8
  • 45
  • 63
Monk
  • 1
  • 2
  • 1
    LocalDB and Express aren't the same. Installing Express won't fix the error. How did you "send" the application to your friend? As an installer? – Thom A Dec 02 '21 at 16:41
  • @Larnu is right, they aren't the same thing. Here's some leisure reading: https://stackoverflow.com/questions/10183379/is-there-a-difference-between-sql-server-express-2012-and-localdb – EspressoBeans Dec 02 '21 at 16:43
  • Larnu, I sent it in winrar, exe file and mdf file together in a folder – Monk Dec 02 '21 at 19:17
  • Larnu, what should I do in this situation, how he connect the mdf file? – Monk Dec 02 '21 at 19:30
  • Search "how to deploy application with localdb" – SMor Dec 02 '21 at 19:42
  • See also [what's the issue with AttachDbFilename](https://stackoverflow.com/questions/11178720/whats-the-issue-with-attachdbfilename), you really shouldn't use it. Just `ATTACH` the database normally. This is true even with LocalDB – Charlieface Dec 02 '21 at 19:59

0 Answers0