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;
}