示例#1
0
 private void LoginMysqlbutton_Click(object sender, EventArgs e)
 {
     ip     = ipAddressControl1.Text;
     user   = UserNametextBox.Text;
     pwd    = PwdtextBox.Text;
     basedb = BaseDatatextBox.Text;
     try
     {
         string        ConnectMysql = null;
         MySQLDBHelper _Mysql       = new MySQLDBHelper();
         ConnectMysql = MySQLDBHelper.GetConnectString(ipAddressControl1.Text, UserNametextBox.Text, PwdtextBox.Text, BaseDatatextBox.Text);
         if (0 == _Mysql.Open(ConnectMysql, null))
         {
             this.Visible = false;
             DataMakerFm fm = new DataMakerFm(_Mysql);
             fm.ShowDialog();
             this.Close();
         }
         else
         {
             MessageBox.Show("Mysql连接失败!!!");
         }
     }
     catch (Exception ex)
     {
         string info = StringUtil.buildExceptionInfo(ex);
         MessageBox.Show(info);
     }
 }
示例#2
0
 public static MySQLDBHelper getNewDbHelper()
 {
     try
     {
         string        ConnectMysql = null;
         MySQLDBHelper _Mysql       = new MySQLDBHelper();
         ConnectMysql = MySQLDBHelper.GetConnectString(ip, user, pwd, basedb);
         if (0 == _Mysql.Open(ConnectMysql, null))
         {
             return(_Mysql);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(StringUtil.buildExceptionInfo(ex));
     }
     return(null);
 }