简体   繁体   中英

Database not working when published my c# project

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM