MYSQL Database Access Issue: please help me!

Status
Not open for further replies.

foxes2

New Member
Messages
5
Reaction score
0
Points
0
Hi all,
I'm publishing my website and I'm getting crazy trying to solve some problems accessing to mysql database.
I have developped my website with asp.net.
The connection string that I use for the connection to the database is the following:
"Database=databaseName;Data Source=mysql.x10hosting.com;Port=3306;User Id=username;Password=password;"
For databaseName and username I use the prefix "cPanelUser_".
I've also added "%.x10hosting.com" in the remote mysql list.
What is the problem?
Can someone help me?
Hoping in your help,
foxes2
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
use localhost as the "Data Source"

the mysql servers on the free servers do not accept remote connections. Only connections from localhost.
 

foxes2

New Member
Messages
5
Reaction score
0
Points
0
I have already tried:
if I use "localhost" as "Data Source" I have the following exception:
"Unable to connect to any of the specified mySql hosts";
if I use "mysql.x10hosting.com" the exception is:
"Access denied for user Username @216.245.211.210 (using password YES)".

I don't understand...
thanks
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
One of the posts in the discussion of this bug suggests setting the connection timeout. Google may turn up other solutions.
 

foxes2

New Member
Messages
5
Reaction score
0
Points
0
No good news setting connection timeout!!
Just for safety,
could you give me your connection strings?
Thanks
Edit:
Today I've re-tried to delete and create the database from scratch. Same thing for the user but nothing changes: I'm still not able to connect to my database!
Help me!!!!!!!!!!!!!
Thanks
 
Last edited:

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Sorry, but I don't use ASP.Net with MySQL on Unix platforms. If you want to make sure your connection string is properly formed, check Connection Strings for your data source provider (MySQL Connector/Net?).

Also, test that MySQL is properly configured. You can use the following:
Code:
<?php
$user='';
$pw='';
$db='';
header('Content-type: text/plain');

function exception_error_handler($errno, $errstr, $errfile, $errline ) {
	throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler");

try {
	$conn = mysql_connect('localhost', $user, $pw);
	mysql_select_db($db);
	$tbls=mysql_query('show tables');
	if ($tbls) {
		echo "Tables in $db:\n";
		while ($row = mysql_fetch_array($tbls, MYSQL_NUM)) {
			echo '  ', $row[0], "\n";
		}
	} else {
		echo "Couldn't list tables.";
	}
} catch (Exception $exc) {
	echo "Couldn't connect to db: ", $exc->getMessage();
}
?>

Set $user, $pw and $db, them save the script somewhere under DOCUMENT_ROOT & open it in a web browser. If it fails, the problem is with your MySQL setup & not your ASP.Net scripts.
 

foxes2

New Member
Messages
5
Reaction score
0
Points
0
Thanks for posting your connection script.
I sent a support ticket and it seems there are some issues with mod_mono (Apache module which allows the execution of ASP.NET scripts) on server side. The administrators are working on it. I hope they'll fix the issue soon.
Is there someone else with the same problem?
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Out of curiosity, I also wrote an ASP.Net app that successfully connects between two development servers (I haven't yet tested it on an X10Hosting server). It uses MySQL Connector/Net as a data provider. Here it is, more or less.

Default.aspx:
HTML:
<%@ Page Language="C#" Inherits="DBTest.Main" AutoEventWireup="true" debug="true" Codebehind="Default.aspx.cs" %>

<!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">
<head runat="server">
    <title>DB Connection Test</title>
</head>
<body>
    <form id="DBTestForm" runat="server">
        <asp:GridView runat="server" ID="resultsTbl" AllowPaging="False" AllowSorting="False" ></asp:GridView>
    </form>
</body>
</html>

Default.aspx.cs:
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Reflection;
using System.Data;
using System.Configuration;
using MySql.Data.MySqlClient;

namespace DBTest {
    public partial class Main : System.Web.UI.Page {
        public Main() {
        }
        public void Page_Load(Object sender, EventArgs e) {
            MySqlConnection dbConn = new MySqlConnection("Data Source=<host>;Port=3306;Database=<db>;User ID=<uid>;Password=<pw>");
            MySqlDataAdapter dbAdapter = new MySqlDataAdapter();
            DataSet result = new DataSet();

            dbAdapter.SelectCommand = new MySqlCommand("SELECT * FROM <table> LIMIT 5", j0Conn);
            dbAdapter.Fill(result);

            resultsTbl.DataSource = result;
            resultsTbl.DataBind();
        }
    }
}
As you can see, it doesn't do much. It's mostly an illustration of 1 way of connecting to a MySQL server. If it were actual production code, things like the connection string would be handled differently. For anyone using this: make sure you set <host>, <db>, <uid>, <pw> and <table>.
 

foxes2

New Member
Messages
5
Reaction score
0
Points
0
Thanks for your post!

I exactly do the same thing: on my computer it works perfectly but it doesn't on x10Hosting server. Could you please verify if your code works on x10Hosting server? It would be very useful!

Foxes2
 
Status
Not open for further replies.
Top