public void open(bool isAdmin = false) { try { string connectionString = string.Empty; if (isAdmin) connectionString = String.Format("host = '{0}'; user = '******'; password = '******'; database = '{3}'", Host, User_id, Password, Database); else connectionString = String.Format("host = '{0}'; user = '******'; password = '******'; database = '{3}'", Host, DEFAULT_USER, DEFAULT_PASSWORD, DEFAULT_DATABASE); Connection = new MySqlConnection(connectionString); Connection.Open(); } catch (MySqlException mex) { MessageBox.Show("It seems that the Database Authentication was not properly configured", "Fix it"); if (dbSettings == null) { dbSettings = new DatabaseSettings(this); dbSettings.ShowDialog(); } else { dbSettings.ShowDialog(); } ErrorLog.Log(mex); } catch (Exception ex) { ErrorLog.Log(ex); } }
public MySqlDB() { Database = DEFAULT_DATABASE; string mydocuments = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string filepath = mydocuments + @"\Petvet\Database\connection"; if (File.Exists(filepath)) { using (StreamReader sr = new StreamReader(filepath)) { Host = sr.ReadLine(); User_id = sr.ReadLine(); Password = sr.ReadLine(); } } else { dbSettings = new DatabaseSettings(this); dbSettings.ShowDialog(); } }
public MySqlDB() { Database = DEFAULT_DATABASE; string local = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); string filepath = local + @"\Exogenesis\Database\connection"; if (File.Exists(filepath)) { using (StreamReader sr = new StreamReader(filepath)) { Host = sr.ReadLine(); User_id = sr.ReadLine(); Password = sr.ReadLine(); } } else { dbSettings = new DatabaseSettings(this); dbSettings.ShowDialog(); } }
public void open() { try { string connectionString = String.Format("host = '{0}'; user = '******'; password = '******'; database = '{3}'", Host, User_id, Password, Database); Connection = new MySqlConnection(connectionString); Connection.Open(); } catch (MySqlException mex) { MessageBox.Show("It seems that the Database Autentication was not properly configured", "Fix it"); if (dbSettings == null) { dbSettings = new DatabaseSettings(this); // dbSettings.button1.Click += button1_Click; dbSettings.ShowDialog(); } ErrorLog.Log(mex); } catch (Exception ex) { ErrorLog.Log(ex); } }