Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用mysql连接asp.net中的远程数据库?_C#_Mysql_Asp.net - Fatal编程技术网

C# 如何使用mysql连接asp.net中的远程数据库?

C# 如何使用mysql连接asp.net中的远程数据库?,c#,mysql,asp.net,C#,Mysql,Asp.net,在localhost中,它工作得非常好。一旦我设置了远程链接而不是本地主机。它不再连接了。我遇到异常,例如无法连接到任何指定的MySQL主机。请尝试以下操作: 我希望这能解决您的问题试试看:- protected void Button1_Click(object sender, EventArgs e) { try { string MyConString = "SERVER=http://10.54.3.208:8080/Ager/person;" + "DA

在localhost中,它工作得非常好。一旦我设置了远程链接而不是本地主机。它不再连接了。我遇到异常,例如无法连接到任何指定的MySQL主机。

请尝试以下操作:

我希望这能解决您的问题

试试看:-

protected void Button1_Click(object sender, EventArgs e)
{
    try
    {
        string MyConString = "SERVER=http://10.54.3.208:8080/Ager/person;" + "DATABASE=agero;" + "UID=root;" + "PASSWORD=root;";
        MySqlConnection con = new MySqlConnection(MyConString);
        //MySqlConnection command = con.CreateCommand();
        con.Open();
        string s = "select * from boopathi where STU_ID =@sid and STU_PWD =@pwd";
        MySqlCommand cmd = new MySqlCommand(s, con);
        cmd.Parameters.AddWithValue("@sid", TextBox1.Text.ToString());
        cmd.Parameters.AddWithValue("@pwd", TextBox2.Text.ToString());
        cmd.ExecuteNonQuery();
        MySqlDataReader dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            if (dr.HasRows == true)
            {
                Server.Transfer("WebForm1.aspx");
            }
        }      
        //close connection
        con.Close();

    }
    catch (Exception ex)
    {
        Response.Write("An error occured: " + ex.Message);
    }
}

有关更多信息,请参阅此链接


我希望它可以帮助您。

我想端口3306在您的网络路径中被阻塞了。引发的异常是什么?我无法连接到任何指定的MySQL主机。请将其编辑到您的问题中,这是非常相关的。您是否已经检查端口3306是否被阻塞?
MySqlConnection c = new MySqlConnection("server=10.54.3.208; database=agero; uid=root; pwd=root");
string MyConString = "SERVER=10.54.3.208;" + "DATABASE=agero;" + "UID=root;" + "Pwd=root;";