private void frmMain_Shown(object sender, EventArgs e) { mMysql = new MySqlWrapper("178.77.65.232", 3306, "insanero", "NNDRDFFB3xmXwK9q", "insanero"); EMysqlConnectionError result = mMysql.Prepare(); if (result != EMysqlConnectionError.None) { MessageBox.Show("Datenbanmk Verbindung failed: " + result.ToString()); Close(); return; } cmbType.SelectedIndex = 0; }
/// <summary> /// Tests the connection details and try to open a <see cref="MySqlConnection"/> /// <para>If opened successfully, its closed afterwards</para> /// <para>Also, if opened, the returned value will be the return from <see cref="Close"/> method</para> /// </summary> public EMysqlConnectionError Prepare() { ConnectionString = String.Format("SERVER={0};PORT={1};UID={2};PASSWORD={3};DATABASE={4};", mServer, mPort, mUser, mPassword, mDatabase); if (AdditionalSettings != "") { ConnectionString += ";" + AdditionalSettings; } Connection = new MySqlConnection(ConnectionString); EMysqlConnectionError result = Open(); if (result == EMysqlConnectionError.None) { result = Close(false); } return(result); }