I have written a C# desktop (winforms) application which is essentially a clone of a web application I wrote. The web application is able to talk back and forth with the database just fine. However, when I install the desktop application, I get the following error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server
I am using the exact same connection string in the desktop application as I am using in the web app which looks like this:
"Data Source=tcp:s08.winhost.com;Initial Catalog=THEDATABASE;
User ID=USERNAME;Password=******;Integrated Security=False;"
I am unable to use SQL Server Configuration Manager as my databases are hosted on Winhost.com. However they have made it clear to me that the proper ports are open, named pipes are on and SQL Browser is configured correctly. If anyone has had a similar problem, please let me know what you did to resolve this issue. I have also included the entire error below.
Thanks
************** Exception Text **************
System.Data.SqlClient.SqlException (0x80131904): 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: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) ---> System.ComponentModel.Win32Exception (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Remove TCP protocol name and port number and try with full hosting website address..something like this
Data Source=www.winhost.com;Initial Catalog=THEDATABASE;
User ID=USERNAME;Password=**;Integrated Security=False;
Eventually I found that the problem was a proxy server. The application is being used by corporations who have proxy servers setup and due to this port 1433 was blocked. I ended up resolving the issue by creating a webservice.
Related
I have been going at this for hours, but have had no success with the current posts out there.
Tried methods:
Enabling TCP
Allowing Remote Connections for the database
Adding new inbound and outbound rules
All these things still do not let me login from my other computer. When I connect on my main computer, everything is instant, but when I tried on my secondary one, it takes a long time before giving me the error:
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 1326)
Is there anyway of fixing this? I don't think watching more Youtube tutorials will help.
I have an application running on a server which has a SqlDependency / query notification - monitoring changes on a table on a different server.
It works fine until we reboot/restart SQL Server. When SQL Server is rebooted due to some maintenance and patches, the other application throws the following errors and stops. I can definitely say it stops because it does not monitor changes once the SQL Server is up and running.
I have to restart the application to resubscribe to the query notification. I am not throwing any exception inside the code that would stop the application. I am catching the exception and sending an email.
System.Data.SqlClient.SqlException (0x80131904): A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.) --->
System.Data.SqlClient.SqlException (0x80131904): 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.
I am new to SqlDependency / query notifications so I am not sure whether this is an expected behaviour or something I am doing wrong. It's my understanding(from other posts (SqlDependency Reliablity?) that I don't have to restart the job to resubscribe.
Appreciate your time and answers
This is normal because when you restart the sql server, the service was stopped and any application that is connected to sql server will be thrown this error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server.
To avoid this problem, you can use a different instance for every application. You can install new server instances with different names to avoid this issue. Which when you restart a single sql server instance, the other sql server instance will still remain online.
You can follow these steps to install or create a new sql server instance:
https://4sysops.com/archives/how-to-create-a-new-sql-server-2012-instance/
Occasionally our web application throws:
System.Data.SqlClient.SqlException (0x80131904): 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception (0x80004005): The network path was not found
Now I have Googled maybe all kinds of variations regarding this error but all seem to point to the fact that the destination SQL server is either down or doesn't accept remote connections or something wrong with the connection string.
But my scenario is different, I can definitely reach the SQL Server (separate machine, same LAN) and this application runs normally most of the time, but in certain instances it starts to generate these errors. Then, apparently, they stop on their own then randomly they start again. Other applications on the same server to the same SQL Server (though different databases) throw these errors as well during the same period.
I have left a continuous ping between the two servers and I can confirm that during this period both servers have IP connectivity between them.
What could be the cause of this problem? What can I check next?
Did you make sure that TCP/IP is enabled under Sql Server Configuration management->SQL Server network config->protocols ?
I have been developing a basic Azure based web application and have run into a problem. The application queries a database that is hosted on Azure and returns the values to the user. When I run the application locally on my private wifi network and when I deploy the application to Azure, it runs fine and the queries are returned correctly. However, when I run the application locally on my companys wifi, I get the following error:
An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code
Additional information: 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: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.)
Can anyone tell me if there is any additional code I need to add or what exception I need to ask to be put in the company's firewall in order to allow me to run and test the application locally?
I have made a windows service and through that service I am doing operations on the database. The machine that I have installed the service is in India and the server is in Singapore. When this service runs I get an error such as
" 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: TCP
Provider, error: 0 - No connection could be made because the target
machine actively refused it.) "
I have a connection string such as
return "server=122.0.122.222,5222;database=ABCD;user id=abc101;password=xyz";
this is in a function that is returning a string. I am catching this string in another string and passing it to the connection object.M I doing anything wrong here.?
But I have tested this service at my house. It works just fine. But when deployed at clients end I get the above error. Any idea why this mite be happening.? Is it related to internet connection but the internet connection is fine. DO I have to give some permissions from my service to make a connection or the IT team of the client should have to give some permissions at their end.?
Please help.
Thanks In advance