private void ConfigureDataBase(string serverName, string userId, string password, string ApplicationPath)
        {
            try
            {
                SClass ClassS = new SClass();
                if (ClassS.CheckMsSqlConnection(serverName, userId, password, ApplicationPath))
                {
                    ClassS.UpdateAppConfig("MsSqlServer", serverName);
                    ClassS.UpdateAppConfig("MsSqlUserId", userId);
                    ClassS.UpdateAppConfig("MsSqlPassword", password);
                    ClassS.UpdateAppConfig("ApplicationPath", ApplicationPath);

                    serverName      = (ConfigurationManager.AppSettings["MsSqlServer"] == null || ConfigurationManager.AppSettings["MsSqlServer"].ToString() == string.Empty) ? null : ConfigurationManager.AppSettings["MsSqlServer"].ToString();
                    userId          = (ConfigurationManager.AppSettings["MsSqlUserId"] == null || ConfigurationManager.AppSettings["MsSqlUserId"].ToString() == string.Empty) ? null : ConfigurationManager.AppSettings["MsSqlUserId"].ToString();
                    password        = (ConfigurationManager.AppSettings["MsSqlPassword"] == null || ConfigurationManager.AppSettings["MsSqlPassword"].ToString() == string.Empty) ? null : ConfigurationManager.AppSettings["MsSqlPassword"].ToString();
                    ApplicationPath = (ConfigurationManager.AppSettings["ApplicationPath"] == null || ConfigurationManager.AppSettings["ApplicationPath"].ToString() == string.Empty) ? null : ConfigurationManager.AppSettings["ApplicationPath"].ToString();
                    if (ClassS.CheckMsSqlConnection(serverName, userId, password, ApplicationPath))
                    {
                        Environment.ExitCode = 100;
                        this.Close();
                    }
                    else
                    {
                        Environment.ExitCode = 101;
                        this.Close();
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Example #2
0
        /// <summary>
        /// Function for check the DataBase Connection
        /// </summary>
        /// <returns></returns>
        private bool CheckDataBase()
        {
            bool   isTrue          = false;
            string serverName      = (ConfigurationManager.AppSettings["MsSqlServer"] == null || ConfigurationManager.AppSettings["MsSqlServer"].ToString() == string.Empty) ? null : ConfigurationManager.AppSettings["MsSqlServer"].ToString();
            string userId          = (ConfigurationManager.AppSettings["MsSqlUserId"] == null || ConfigurationManager.AppSettings["MsSqlUserId"].ToString() == string.Empty) ? null : ConfigurationManager.AppSettings["MsSqlUserId"].ToString();
            string password        = (ConfigurationManager.AppSettings["MsSqlPassword"] == null || ConfigurationManager.AppSettings["MsSqlPassword"].ToString() == string.Empty) ? null : ConfigurationManager.AppSettings["MsSqlPassword"].ToString();
            string ApplicationPath = (ConfigurationManager.AppSettings["ApplicationPath"] == null || ConfigurationManager.AppSettings["ApplicationPath"].ToString() == string.Empty) ? null : ConfigurationManager.AppSettings["ApplicationPath"].ToString();
            string isSqlServer     = (ConfigurationManager.AppSettings["isServerConnection"] == null || ConfigurationManager.AppSettings["isServerConnection"].ToString() == string.Empty) ? null : ConfigurationManager.AppSettings["isServerConnection"].ToString();
            SClass objDb           = new SClass();

            if (objDb.CheckMsSqlConnection(serverName, userId, password, ApplicationPath))
            {
                isTrue = true;
            }
            else
            {
                isTrue = false;
            }
            return(isTrue);
        }