Esempio n. 1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            // TODO:
            // Change NIRS_Viewer.Properties.Settings.nirsConnectionString and reinitialize NIRS_DataSet
            // Good luck :)

            DBSettings dbsettings = new DBSettings(
                txtHost.Text,
                txtPort.Text,
                txtUser.Text,
                txtPassword.Text,
                txtDB.Text
            );

            try
            {
                DBConnection.Connection(dbsettings);
                this.Close();
            }
            catch (Exception ex)
            {
                Logs.WriteLine(ex.ToString());
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
 public static void Connection(DBSettings settings)
 {
     string connection_string = "Server=" + settings.host + ";Port=" + settings.port +";Database=" + settings.database +
         ";Uid=" + settings.user + ";Pwd=" + settings.pwd +";";
     MySqlConnection conn = new MySqlConnection(connection_string);
     try
     {
         conn.Open();
         _dbc = new DBConnection(conn);
         InstalledSettings = settings;
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
         throw;
     }
 }