Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Connect to MySQL using MySQL Connector.NET and SharpSsh

$
0
0
Hi,

I am trying to connect to MySQL using the MySQL Connector.NET and SharpSsh but getting Unable to connect to MySQL although my SSH was successfully connected.

Can anyone help please...

Here is my code:

private void btnExecSSH_Click(object sender, EventArgs e)
{
    SshExec exec = new SshExec("10.0.0.111", "root");
    exec.Password = "myPassword";

    exec.Connect(22);

    MessageBox.Show("SSH Connected");

    btnMySQL.PerformClick();
}

private void btnMySQL_Click(object sender, EventArgs e)
{
    try
    {
        sql_connection = new MySqlConnection("server = 10.0.0.111; Port = 3306; Database = bizcards; Uid = root; Pwd = myPassword;");
        sql_connection.Open();

        MessageBox.Show("Connected!", "Yahoo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
    catch (Exception exp)
    {
        MessageBox.Show(String.Format("Error:{0}{1}", Environment.NewLine, exp.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
}



Viewing all articles
Browse latest Browse all 8156


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>