示例#1
0
        public string FormConnectionString(string settingsDocument)
        {
            //grab the proper information from the form
            //declare applicable vars
            string serverType = string.Empty;
            string serverName = string.Empty;
            string UserName   = string.Empty;
            string password   = string.Empty;

            string[] newServerInfo = new string[4];

            //fill the strings with xml information
            //call the function in class
            var newServerInstance = new parseXml();

            newServerInfo = newServerInstance.settingsParser(settingsDocument);
            serverType    = newServerInfo[0];
            serverName    = newServerInfo[1];
            UserName      = newServerInfo[2];
            password      = newServerInfo[3];

            //form the connection string
            string connectionString = null;

            //SqlConnection cnn;
            connectionString = string.Empty;
            connectionString = string.Concat("serverType=", serverType, ";serverName=", serverName, ";UserName="******";password="******";");
            return(connectionString);
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try //to open and read the settings xml file
            {
                //put code here to connect to database using provided information
                //detect what's inside of textBox3
                string settingsFile = string.Empty;
                settingsFile = formXmlDoc.Text;

                var      readSettings  = new parseXml();
                string[] settingsArray = new string[4];
                //settingsFile is the name of the file in the formXmlDoc element of the desktop software
                settingsArray = readSettings.settingsParser(settingsFile);
            }
            catch
            {
                //message box goes here
                var showMessage = new messageBox("ERROR 41: Unable to open or read the XML file.");
                showMessage.getANewMessage("ERROR 41: Unable to open or read the XML file.");
            }
            try //to declare the empty variables for individually manipulable objects
            {
                //put code here to connect to database using provided information
                //detect what's inside of textBox3
                string settingsFile = string.Empty;
                settingsFile = formXmlDoc.Text;

                var      readSettings  = new parseXml();
                string[] settingsArray = new string[4];
                //settingsFile is the name of the file in the formXmlDoc element of the desktop software
                settingsArray = readSettings.settingsParser(settingsFile);

                //declare some variables for imos
                //shove that array information into individually manipulatable objects
                string databaseType = string.Empty;
                string serverName   = string.Empty;
                string username     = string.Empty;
                string password     = string.Empty;
            }
            catch
            {
                //message box goes here
                var showMessage = new messageBox("ERROR 42: Unable to read the XML file.");
                showMessage.getANewMessage("ERROR 42: Unable to read the XML file.");
            }
            try //to convert strings from DB establish connection
            {
                //put code here to connect to database using provided information
                //detect what's inside of textBox3
                string settingsFile = string.Empty;
                settingsFile = formXmlDoc.Text;

                var      readSettings  = new parseXml();
                string[] settingsArray = new string[4];
                //settingsFile is the name of the file in the formXmlDoc element of the desktop software
                settingsArray = readSettings.settingsParser(settingsFile);

                //declare some variables for imos
                //shove that array information into individually manipulatable objects
                string databaseType = string.Empty;
                string serverName   = string.Empty;
                string username     = string.Empty;
                string password     = string.Empty;

                databaseType = settingsArray[0];
                serverName   = settingsArray[1];
                username     = settingsArray[2];
                password     = settingsArray[3];

                //assume correctness
                //close the active window
                this.Close();
                var showMessage = new messageBox("Success: Settings read success. (INFO 44)");
                showMessage.getANewMessage("Success: Settings read success. (INFO 44)");
            }
            catch
            {
                //message box
                var showMessage = new messageBox("ERROR 43: Unable to convert XML array to string.");
                showMessage.getANewMessage("ERROR 43: Unable to convert XML array to string.");
            }
        }