Azavea.Open.DAO.PostgreSQL.PostgreSqlDescriptor.MakeConnectionString C# (CSharp) Method

MakeConnectionString() public static method

Assembles a PostGreSQL/PostGIS connection string that can be used to get a database connection. All the parameters are optional for the purposes of this method, although obviously it would be possible to create a useless connection string if you leave out important parameters.
public static MakeConnectionString ( string server, string port, string database, string user, string password, string encoding ) : string
server string Server name that is hosting the database
port string Port number on the server to use, if you don't know then use DEFAULT_PORT.
database string Database name, if necessary to specify
user string User name to use when accessing the db
password string Password for above user, in plain text.
encoding string String encoding to use, if you don't know then use DEFAULT_ENCODING.
return string
        public static string MakeConnectionString(string server, string port,
            string database, string user, string password, string encoding)
        {
            string connStr = "";

            // Assemble the string.  Only include parameters that have values.
            if (StringHelper.IsNonBlank(server))
            {
                connStr += "Server=" + server + ";";
            }
            if (StringHelper.IsNonBlank(port))
            {
                connStr += "Port=" + port + ";";
            }
            if (StringHelper.IsNonBlank(encoding))
            {
                connStr += "Encoding=" + encoding + ";";
            }
            if (StringHelper.IsNonBlank(database))
            {
                connStr += "Database=" + database + ";";
            }
            if (StringHelper.IsNonBlank(user))
            {
                connStr += "User ID=" + user + ";";
            }
            if (StringHelper.IsNonBlank(password))
            {
                connStr += "Password=" + password + "";
            }
            return connStr;
        }