コード例 #1
0
ファイル: SplashScreenForm.cs プロジェクト: FallenAngel7/IE
        private async Task <bool> CheckDbConnection(string dbName)
        {
            if (dbName == "IE")
            {
                lblStatus.Text = "در حال بررسی ارتباط با سرور راهکاران...";
            }
            else
            {
                lblStatus.Text = "در حال بررسی ارتباط با سرور دلفی...";
            }
            var connectionString = "";

            connectionString = ConfigurationManager.ConnectionStrings[dbName + "ConnectionString"].ConnectionString;
            var connectionStringBuilder = new SqlConnectionStringBuilder(connectionString);

            connectionStringBuilder.InitialCatalog = "master";


            if (!await CheckDbConnection(connectionStringBuilder))
            {
                var DBSettingForm = new DBConnectionStringForm(dbName);

                var result = DBSettingForm.ShowDialog();
                if (result != DialogResult.OK)
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #2
0
        private async Task <bool> CheckDbConnection(string db)
        {
            var connectionString        = ConfigurationManager.ConnectionStrings[dbName + "ConnectionString"].ConnectionString;
            var connectionStringBuilder = new SqlConnectionStringBuilder(connectionString);

            connectionStringBuilder.InitialCatalog = "master";


            if (!await CheckDbConnection(connectionStringBuilder))
            {
                var DBSettingForm = new DBConnectionStringForm(dbName);

                var result = DBSettingForm.ShowDialog();
                if (result != DialogResult.OK)
                {
                    return(false);
                }
            }

            return(true);
        }