ASP.Net file unable to connect remote MySql Server

ml123me

New Member
Messages
3
Reaction score
0
Points
0
Hi,

I have created database on absolut.x10hosting.com (IP 115.96.178.41) with database name ml123me_test.

After that i uploaded my project files to the CPanel. Following is the code


Default.aspx

<%@ Page Language="C#"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="MySql.Data.MySqlClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<script runat="server">
private void Page_Load(Object sender, EventArgs e)
{
string connectionString = "server=absolut.x10hosting.com;Database=ml123me_test;userid=ml123me;password=******;Pooling=false;";
MySqlConnection dbcon = new MySqlConnection(connectionString);
dbcon.Open();

MySqlDataAdapter adapter = new MySqlDataAdapter("SELECT * FROM emp", dbcon);
DataSet ds = new DataSet();
adapter.Fill(ds, "emp");

dbcon.Close();
dbcon = null;

GridView1.DataSource = ds.Tables["emp"];
GridView1.DataBind();
}
</script>
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="GridView1" runat="server"></asp:GridView>
</form>
</body>
</html>



It gives as error as follows :

System.Net.Sockets.SocketException: Connection refused

at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remote_end) [0x00000]
at System.Net.Sockets.Socket+Worker.Connect () [0x00000]




If i change the server to the IP address 115.96.178.41

It gives error as follows :

MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts.
at MySql.Data.MySqlClient.NativeDriver.Open () [0x00000]
at MySql.Data.MySqlClient.Driver.Open () [0x00000]
at MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) [0x00000]
at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00000]




Please help me on this topic.

Thanks in advance.
 
Last edited:

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
The MySQL host is localhost. The remote MySQL feature has been disabled on the free servers.
 

ml123me

New Member
Messages
3
Reaction score
0
Points
0
Thanks for the help.

But even if i make server as a localhost in connection string it gives following error


Server Error in '/' Application

Connection refused Description: HTTP 500. Error processing request.
Stack Trace:
System.Net.Sockets.SocketException: Connection refused
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remote_end) [0x00000]
at System.Net.Sockets.Socket+Worker.Connect () [0x00000]
Version information: Mono Version: 2.0.50727.1433; ASP.NET Version: 2.0.50727.1433



Please let me know if some changes need to be done.
 
Top