SqlException (0x80131904) connecting mdf database

I have a C # application that connects to a SQL Server database file .mdf, which is in the root of my application directory. The application is distributed among other users in the company. They get the following error:

System.Data.SqlClient.SqlException (0x80131904): A network-related or specific instance error occurred while establishing a connection to SQL Server. The server was not found or was not available. Verify the instance name is correct and configure SQL Server to connect remotely. (provider: SQL network interfaces, error: 26 - server / instance location error)

Not all users receive this error. I assume this is a security bug. Below is the connection string. Any idea what causes this problem and how to solve it?

<add name="EditorConnectionString" 
     connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Resources.mdf;Integrated Security=True;User Instance=True;Persist Security Info=true;Connection Timeout=130" 
     providerName="System.Data.SqlClient" />
+3
source share
1 answer

If you are using the approach AttachDbFileName=...in the connection string, SQL Server, used for this MUST BE , Express .

In addition, since the connection string contains .\SQLEXPRESSas the value Data Source=, this instance of SQL Server Express must run locally on this particular machine (this value is .in Data Source=)

+3
source

All Articles