示例#1
0
        //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);
        }
示例#2
0
        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);
            }
        }
示例#3
0
 //Constructor
 public SQLConnect(string sysDirectory)
 {
     systemDirectory = sysDirectory;
     sqlInfo         = xmlSQLInfo(sqlInfo);
     Initialize(sqlInfo);
 }