Editing the Connect button code
I am going to show you the code which would be activated when the connect button clicked.The code on click event is as follows-
Code:
private void btnConnect_Click(object sender, EventArgs e)
{
ConStr = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=" + txtIP.Text + ";PORT=" + txtPort.Text + ";DATABASE=" + txtDatabase.Text + ";UID=" + txtUsername.Text + ";PWD=" + txtPassword.Text + ";OPTION=3";
OdbcCon = new System.Data.Odbc.OdbcConnection(ConStr);
btnListTables.Enabled = true;
try
{
txtLog.AppendText("Openning connection...\r\n");
if (OdbcCon.State == ConnectionState.Closed)
{
OdbcCon.Open();
txtLog.AppendText("Connection opened\r\n");
}
}
catch (System.Data.Odbc.OdbcException Ex)
{
txtLog.AppendText(Ex.Message + "\r\n");
}
}
Bookmarks