Exemple #1
0
        protected void TestSqlSettingsClick(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(textboxSqlDatabase.Text) || String.IsNullOrEmpty(textboxSqlServerPath.Text) ||
                String.IsNullOrEmpty(textboxSqlUsername.Text) || String.IsNullOrEmpty(textboxSqlPassword.Text))
            {
                labelMessage.Text = "You must complete all the SQL configuration fields to test your SQL connectivity";
                return;
            }

            AbstractSqlConfiguration sqlConfig = new MsSqlConfiguration();

            sqlConfig.Database = textboxSqlDatabase.Text;
            sqlConfig.Hostname = textboxSqlServerPath.Text;
            sqlConfig.Username = textboxSqlUsername.Text;
            sqlConfig.Password = textboxSqlPassword.Text;

            ConnectionTester dao = new ConnectionTester(sqlConfig.buildConnectionString());

            dto.BoolTO result = dao.canWrite();
            if (result.trueOrFalse)
            {
                labelMessage.Text = "You were able to write to your database with these SQL settings. Good job!";
            }
            else if (result.fault != null)
            {
                labelMessage.Text = "<p>MDWS failed to write to your database with those SQL settings. Maybe the " +
                                    "following error will give you a clue why:</p>" + result.fault.message;
            }
            else
            {
                labelMessage.Text = "MDWS couldn't successfully connect to your database with those parameters " +
                                    "but no error was reported. You got yourself a real pickle there.";
            }
        }