0

I'm developing an ASP.net web application. My default page is a simple login screen. I am using Visual Studio to develop the application.

It will run using Visual Studio and when the data is entered to the text boxes and the button is clicked, it sends the request to my own server running Windows Server 2012 with SQL Server 2014 installed. I will also mention that the ASP application is being created as a secondary application for an Android application. The Android application is using the same database over Internet connection so I know that the server and SQL server both can accept read and write calls.

I have tested the ASP application using WebClient calls to php files which connect to the database (this works on Android) and also OracleClient and SQLClient calls all of which work from Visual Studio on my workstation to the server machine. These all work fine to send and receive data from the database.

The problem is once I deploy the application to my hosting site the calls no longer seem to work. The default login page opens but after attempting to login I receive errors as follows:

Exception Details: System.ComponentModel.Win32Exception: No connection could be made because the target machine actively refused it

[Win32Exception (0x80004005): No connection could be made because the target machine actively refused it]

[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.

Can anyone help me with this?

Community
  • 1
  • 1
  • Could you please kindly check your connection string again? From the error message, it shows that your connection string is incorrect. –  Jul 18 '16 at 03:30
  • @DouglasThomas The connection string was fine. As wrote under Matt Perrys answer is was a block from my hosting package which was not allowing me to connect to an external database. Its all working fine now. Thanks anyway. – Simon Leen Jul 18 '16 at 21:36
  • Glad to hear that.... :) –  Jul 19 '16 at 03:43

1 Answers1

0

It sounds like your database is accepting connections from some clients, but not your hosting server. I would try testing a SQL connection straight from the hosting Server and see if a test connection can be successful. If you can get that to work it should work from the web server.

This article Quick ways to test OLE DB Connection String on creating a empty TestConnection.udl file will be helpful. It is easier to try different connection string settings through the Data Link Properties UI. When you save the file, you can see the connection string if you open it in a text editor (assuming it is successful).

If it's not a problem with he connection string, check that you do not have a firewall blocking connections between the Windows 2012 and SQL servers. It could be the widows firewall on either machine, or another firewall at the network level.

Community
  • 1
  • 1
MattPerry
  • 306
  • 1
  • 7
  • Thanks @MattPerry for your reply. I tested the connection from multiple machines and using Data Link properties. I also turned off firewalls on both machines. It turns out that my the hosting package does not allow using external databases of any sort. So only options are to host the ASP off the database server or migrate the database to the hosting server. Hopefully this will be useful for anyone else that comes across this issue – Simon Leen Jul 15 '16 at 16:07