public void createLogFile(DBinfo dbconnstring) { string connString = @"server=" + dbconnstring.ServerName + ";userid=root" + ";password=metalic"; cnnLog = new MySqlConnection(connString); string db; try { cnnLog.Open(); } catch (MySqlException ex) { MessageBox.Show("Can not open connection ! \n" + ex.ToString()); } cmd.Connection = cnnLog; /*if (db == null) * { * db = dbconnstring.DBName.Replace("_data", ""); * } * else * {*/ db = dbconnstring.DBName; db = db.Replace("_data", ""); //} cmd.CommandText = "CREATE DATABASE IF NOT EXISTS " + db + "_log"; try { cmd.ExecuteNonQuery(); } catch (MySqlException ex) { MessageBox.Show("\n" + ex.ToString()); } cmd.CommandText = "USE " + db + "_log;"; try { cmd.ExecuteNonQuery(); } catch (MySqlException ex) { MessageBox.Show("\n" + ex.ToString()); } string path = Path.GetDirectoryName(Application.ExecutablePath); //path = path.Replace(@"bin\Debug", ""); MySqlScript script = new MySqlScript(cnnLog, File.ReadAllText(path + "\\SQLLOG2203.sql")); script.Delimiter = "***"; script.Execute(); }
public string getConnectionString(DBinfo dbconnstring) { return("Data Source=" + dbconnstring.ServerName + ";Initial Catalog=" + dbconnstring.DBName + ";User ID=root" + ";Password=metalic"); }