1

I developed an application in C# using visual studio 2015. But when I published the application and run it on another system. It gives the following exceptions.

" A network related or instance specific error occurred while establishing a connection to SQL server. The server was not found or was not accessbile. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. Unable to locate a local database runtime installation.

7
  • Please provide some code or your connectionstring you are using. The error would also be helpful to know whats going wrong. Commented Aug 27, 2015 at 6:33
  • Did you check your connection string? Commented Aug 27, 2015 at 6:33
  • Here is the connection string, I am realizing that it would not work on someone else computer, but what to write instead of it? string con_strr = @"Data Source=.\SQLEXPRESS;AttachDbFilename='C:\Users\MAHMOOD\Documents\Visual Studio 2010\Projects\childcare_software\childcare_software\Database1.mdf';Integrated Security=True;User Instance=True"; Commented Aug 27, 2015 at 6:39
  • did you get SQL Db hosting somewhere? Commented Aug 27, 2015 at 6:41
  • No, what is SQL Db hosting? Commented Aug 27, 2015 at 6:43

1 Answer 1

1

While publishing database, we need to cleanup the dev configurations a little further.

In the connection string check what is the Database server name on your client hosting environment and include that in: Data Source="Client database host server name"

Also instead of providing .mdf file ( as specified in your connection string with AttachDbFilename='C:\Users...'), better would be either generate the script from SQL Management studio in your local and run those in your client environment.

If it is by requirement to provide .mdf file then make sure the path to mdf file in hosting environment matches to what you give in your connection string.

Or else you can provide mdf file to client ask them to attach it to the hosted database server.

Often, Integrated Security might not be provided on host servers. So check the userid/password with your client on hosting machine to connect and update them in your connection string.

Hope some of these point might help you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.