MySQL Forums
Forum List  »  Newbie

Connect to MySQL using MySQL Connector.NET and SharpSsh
Posted by: Jassm Rahma
Date: June 24, 2014 12:20AM

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);
}
}

Options: ReplyQuote


Subject
Written By
Posted
Connect to MySQL using MySQL Connector.NET and SharpSsh
June 24, 2014 12:20AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.