コード例 #1
0
        public string Authenticate(string serverName)
        {
            if (string.IsNullOrEmpty(serverName))
            {
                MessageBoxWrapper.ShowErrorBox("Server name is empty", "Please provide a server name.");
                return(null);
            }

            string connectionString        = _sqlConnectionBuilder.BuildForWindowsAuthentication(serverName);
            bool   isValidConnectionString = ValidateConnectionString(connectionString);

            if (!isValidConnectionString)
            {
                MessageBoxWrapper.ShowErrorBox("Invalid server name", "Please provide a valid server name.");
                return(null);
            }

            return(connectionString);
        }
コード例 #2
0
        public string Authenticate(string serverName, string login, string password)
        {
            if (string.IsNullOrEmpty(serverName) || string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
            {
                MessageBoxWrapper.ShowErrorBox("Fill the boxes", "Please fill all the boxes, before connecting to the server.");
                return(null);
            }

            string connectionString        = _sqlConnectionBuilder.BuildForWindowsAuthentication(serverName);
            bool   isValidConnectionString = ValidateConnectionString(connectionString);

            if (!isValidConnectionString)
            {
                MessageBoxWrapper.ShowErrorBox("Invalid server name", "Please provide a valid server name.");
                return(null);
            }

            return(connectionString);
        }
コード例 #3
0
 public LoginForm(IServerAuthentication serverAuthentication)
 {
     InitializeComponent();
     string[] dataSourceNames = null;
     try
     {
         dataSourceNames = SqlServerInfo.GetDataSourceName().ToArray();
         serverName_Dropdown.Items.AddRange(dataSourceNames);
         authenticationType_ComboBox.SelectedIndex = 0;
         serverName_Dropdown.SelectedIndex         = 0;
         _serverAuthentication = serverAuthentication;
     }
     catch (Exception)
     {
         if (dataSourceNames is null)
         {
             MessageBoxWrapper.ShowErrorBox("None Sql Server Instances", "No Sql Server Instances were found in your computer");
         }
     }
 }