//Initialize values private void Initialize(SQLInfo info) { server = info.getServer(); //"localhost"; database = info.getDataBase(); //"userdatabasecm"; uid = info.getId(); //"codeadmin"; password = info.getPassword(); //"-password024-"; string connectionString; connectionString = "SERVER=" + server + ";" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD="******";"; connection = new MySqlConnection(connectionString); }
public SQLInfo xmlSQLInfo(SQLInfo info) { string server = "null"; string database = "null"; string uid = "null"; string password = "******"; try { string directoryVal = systemDirectory + "\\sqlinfo.xml"; XmlDocument doc = new XmlDocument(); doc.Load(directoryVal); foreach (XmlNode node in doc.DocumentElement.ChildNodes) { string element = node.Name; string val = node.InnerText; if (element == "Server") { server = val; } else if (element == "Database") { database = val; } else if (element == "UserId") { uid = val; } else if (element == "Password") { password = val; } } SQLInfo sqlInfo = new SQLInfo(server, database, uid, password); return(sqlInfo); } catch (Exception Ex) { // have bad info SQLInfo sqlInfo = new SQLInfo(server, database, uid, password); return(sqlInfo); } }
//Constructor public SQLConnect(string sysDirectory) { systemDirectory = sysDirectory; sqlInfo = xmlSQLInfo(sqlInfo); Initialize(sqlInfo); }