예제 #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);
            }
        }
예제 #2
0
파일: DBConnection.cs 프로젝트: brunql/NIRS
 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;
     }
 }