Example #1
0
        /// <summary>
        /// Create an instance of the database client.
        /// </summary>
        /// <param name="serverIp">The IP address or hostname of the database server.</param>
        /// <param name="serverPort">The TCP port of the database server.</param>
        /// <param name="username">The username to use when authenticating with the database server.</param>
        /// <param name="password">The password to use when authenticating with the database server.</param>
        /// <param name="instance">The instance on the database server (for use with Microsoft SQL Server).</param>
        /// <param name="database">The name of the database with which to connect.</param>
        public DatabaseClient(
            string serverIp,
            int serverPort,
            string username,
            string password,
            string instance,
            string database)
        {
            if (String.IsNullOrEmpty(serverIp))
            {
                throw new ArgumentNullException(nameof(serverIp));
            }
            if (serverPort < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(serverPort));
            }
            if (String.IsNullOrEmpty(database))
            {
                throw new ArgumentNullException(nameof(database));
            }

            _ServerIp         = serverIp;
            _ServerPort       = serverPort;
            _Username         = username;
            _Password         = password;
            _Instance         = instance;
            _DatabaseName     = database;
            _ConnectionString = SqlServerHelper.ConnectionString(_ServerIp, _ServerPort, _Username, _Password, _Instance, _DatabaseName);
        }
Example #2
0
 /// <summary>
 /// Create an instance of the database client.
 /// </summary>
 /// <param name="settings">Database settings.</param>
 public DatabaseClient(DatabaseSettings settings)
 {
     _Settings = settings ?? throw new ArgumentNullException(nameof(settings));
     if (_Settings.Type != DbTypes.SqlServer)
     {
         throw new ArgumentException("Database settings must be of type 'SqlServer'.");
     }
     _ConnectionString = SqlServerHelper.ConnectionString(_Settings);
 }
Example #3
0
        /// <summary>
        /// Create an instance of the database client.
        /// </summary>
        /// <param name="serverIp">The IP address or hostname of the database server.</param>
        /// <param name="serverPort">The TCP port of the database server.</param>
        /// <param name="username">The username to use when authenticating with the database server.</param>
        /// <param name="password">The password to use when authenticating with the database server.</param>
        /// <param name="instance">The instance on the database server (for use with Microsoft SQL Server).</param>
        /// <param name="database">The name of the database with which to connect.</param>
        public DatabaseClient(
            string serverIp,
            int serverPort,
            string username,
            string password,
            string instance,
            string database)
        {
            if (String.IsNullOrEmpty(serverIp))
            {
                throw new ArgumentNullException(nameof(serverIp));
            }
            if (serverPort < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(serverPort));
            }
            if (String.IsNullOrEmpty(database))
            {
                throw new ArgumentNullException(nameof(database));
            }

            _Settings         = new DatabaseSettings(serverIp, serverPort, username, password, instance, database);
            _ConnectionString = SqlServerHelper.ConnectionString(_Settings);
        }