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); }
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); }