Exemplo n.º 1
0
        /// <summary>
        /// Initializes a connection string for use with integrated security
        /// </summary>
        /// <param name="connectString">A complete connection string to the database</param>
        /// <returns>The initialized connection string data</returns>
        /// <remarks>
        /// The connectString should contain a complete functional connection string, including any necessary
        /// parameters such as userID, password and Integrated Security settings.
        /// </remarks>
        internal static ConnectionStringData GetConnectionStringData(string connectString)
        {
            ArgumentValidation.CheckForEmptyString(connectString, "Connection String");

            ConnectionStringData connectionStringData = GetConnectionStringData();

            // Deconstruct the complete connection string and
            // load it into the connectionStringData object
            BuildConnectionStringDataFromConnectString(connectionStringData, connectString);

            return(connectionStringData);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a connection string for use with integrated security
        /// </summary>
        /// <param name="server">The name of the server to connect to</param>
        /// <param name="database">The name of the database to connect to</param>
        /// <returns>The initialized connection string data</returns>
        internal static ConnectionStringData GetConnectionStringData(string server, string database)
        {
            ArgumentValidation.CheckForEmptyString(server, "Server");
            ArgumentValidation.CheckForEmptyString(database, "Database");

            ConnectionStringData connectionStringData = GetConnectionStringData();

            connectionStringData.Parameters.Add(new ParameterData("Server", server));
            connectionStringData.Parameters.Add(new ParameterData("Database", database));
            connectionStringData.Parameters.Add(new ParameterData("Integrated Security", "True"));

            return(connectionStringData);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Takes a connection string and breaks it down into its component name/value pairs, then loads the pairs
        /// into a <see cref="ConnectionStringData"/> object.
        /// </summary>
        /// <param name="connectionStringData">The data object to be loaded from the connectString</param>
        /// <param name="connectString">The connection string</param>
        /// <remarks>
        /// No attempt is made to validate the connection string nor any of its contents. If the string cannot be parsed
        /// an exception will be thrown.
        /// </remarks>
        internal static void BuildConnectionStringDataFromConnectString(ConnectionStringData connectionStringData, string connectString)
        {
            ArgumentValidation.CheckForNullReference(connectionStringData, "Connection String Data");
            ArgumentValidation.CheckForEmptyString(connectString, "Connect String");

            string[] items = connectString.Split(';');

            foreach (string item in items)
            {
                if (item.Length > 0)
                {
                    string[] parms = item.Split('=');
                    connectionStringData.Parameters.Add(new ParameterData(parms[0], parms[1]));
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a connection string data object initialized with username, password server and database
        /// </summary>
        /// <param name="server">The server to connect to</param>
        /// <param name="database">The database to connect to</param>
        /// <param name="userID">The UserID to connect as</param>
        /// <param name="password">The password to connect as</param>
        /// <returns>An initialized connection string object</returns>
        internal static ConnectionStringData GetConnectionStringData(string server, string database, string userID, string password)
        {
            ArgumentValidation.CheckForEmptyString(server, "Server");
            ArgumentValidation.CheckForEmptyString(database, "Database");
            ArgumentValidation.CheckForEmptyString(userID, "User ID");
            ArgumentValidation.CheckForEmptyString(password, "Password");

            ConnectionStringData connectionStringData = GetConnectionStringData();

            connectionStringData.Parameters.Add(new ParameterData("Server", server));
            connectionStringData.Parameters.Add(new ParameterData("Database", database));
            connectionStringData.Parameters.Add(new ParameterData("User ID", userID));
            connectionStringData.Parameters.Add(new ParameterData("password", password));

            return(connectionStringData);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a connection string for use with integrated security
        /// </summary>
        /// <param name="connectString">A complete connection string to the database</param>
        /// <param name="userID">The UserId to connect as</param>
        /// <param name="password">The password to connect as</param>
        /// <returns>The initialized connection string data</returns>
        /// <remarks>
        /// The connectString should contain a complete functional connection string, including any necessary
        /// parameters such as userID, password and Integrated Security settings.
        /// </remarks>
        internal static ConnectionStringData GetConnectionStringData(string connectString, string userID, string password)
        {
            ArgumentValidation.CheckForEmptyString(connectString, "Connection String");
            ArgumentValidation.CheckForEmptyString(userID, "User ID");
            ArgumentValidation.CheckForEmptyString(password, "Password");

            ConnectionStringData connectionStringData = GetConnectionStringData();

            // Deconstruct the complete connection string and
            // load it into the connectionStringData object
            BuildConnectionStringDataFromConnectString(connectionStringData, connectString);

            // Add the userID and password to the object
            connectionStringData.Parameters.Add(new ParameterData("User ID", userID));
            connectionStringData.Parameters.Add(new ParameterData("password", password));

            return(connectionStringData);
        }