public GForm(string strConn, DbStyle style) { this._strConn = strConn; this._style = style; InitializeComponent(); startup(); }
private void button1_Click(object sender, EventArgs e) { DbStyle style = DbStyle.Mysql; string sport = "0"; string server = "127.0.0.1"; string suser = "******"; switch (cbDB.SelectedIndex) { case 0: { style = DbStyle.Mysql; if (string.IsNullOrEmpty(tbPort.Text)) { sport = "3306"; } else { sport = tbPort.Text.Trim(); } if (!string.IsNullOrEmpty(tbServer.Text)) { server = tbServer.Text.Trim(); } break; } case 1: { style = DbStyle.SqlServer; break; } case 2: { style = DbStyle.Oracle; break; } default: { style = DbStyle.Mysql; break; } } string sconn = string.Format("Data Source = '{0}'; User Id = '{1}'; Password ='******' ; Port='{3}'; charset = 'utf8'; pooling = true", server, suser, tbPwd.Text, sport); GForm gf = new GForm(sconn, style); gf.Show(); this.Hide(); }