Reputation: 622
I developed a small project in visual studio 2010. In my project I attach a service-based database named database1.mdf
.
My connectionString is :
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True
It works fine on my developer pc but it throws an exception on a client's pc.
Exception 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)
I don't understand what is happening.
Upvotes: 1
Views: 760
Reputation: 37533
Two things need to occur before you can connect to a SQL Server Express database.
SQL Server Express must be installed on the target server. Having the file present isn't sufficient. (This is what the error you're experiencing likely means).
The path to your database file should be an absolute path to rule out the possibility of a file location error.
Upvotes: 1
Reputation: 3763
this connection string is for your developer machine. you share your database on the network. you also must update your connection string by adding ip address of your server.
Upvotes: 1