Click here to Skip to main content
15,610,690 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
A network-related or instance-specific error occurred while establishing a connection to SQL Server

What I have tried:

i also using crystal report (32-bit,64-bit)according to client computer and also install sql server management studio because i am using local server db but i dont add database in client sql server managament studio. when i deploy again but it give same error message about sql server.
Updated 27-Mar-22 1:56am

The connection string that you use for development is unlikely to work in production - in fact it definitely should not work as developing software against the production database is a good way to learn "I really should have a better backup system" ... it is far too easy to damage or destroy a database through a minor software bug while developing code!

So start with your app: do you hardcode the connection? If so, that needs fixing - connection strings should always be stored in an app config file so they can be changed without recompilation.

Then check the config file the user is using: make sure he can access the Sql Server instance, and that his Sql login credentials are valid for the access he needs to the actual database your code uses. Then check the instance contains the actual database and that it's tables and data are up-to-date with what you code expects.

Sorry, but we can't do any of that for you!
Share this answer
As Griff suggested, put the connections string in a file, or as a defualt on your inteface. If you test the Crystal report on the same machine as the server and it works, but gives you an error when you run the report from another machine, there can be a few things to try. install SSMS on the remote machine and try connecting to the server from there. if it times out and does not connect, there are probably two main reasons
1 - the server is not listening, TCP/IP port are usually off by default. see link Enable or Disable a Server Network Protocol - SQL Server | Microsoft Docs[^]
2 - Try using "server Authentication" rather than "windows authentication". SQL Server in Microsoft Docs is a good place to start (search for "Change server authentication mode" link Microsoft SQL documentation - SQL Server | Microsoft Docs[^] if server authentication works, but windows authentication doesn't, it is most likely permissions on the server need setting up, Google for SQL scripts that set permissions. You may also need to get both client and sever machines asdded to the same domain and user group for windows authentication to work

there can be numerous reasons, but these were the two that worked for me, setting the ports to listen, and permissions.
Share this answer
This article has. Good troubleshooting guide, with pictures
Resolving could not open a connection to SQL Server errors[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900