I had the same problem as you building the attached solution and that was the only decend way i found. Script itself is not complicated, please find mine below:
public void Main()
{
bool IsValid = true;
string Provider = "SQLNCLI10.1";
string ServerName = Dts.Variables["User::ServerName"].Value.ToString();
string Catalog = Dts.Variables["User::Catalog"].Value.ToString();
string UserId = Dts.Variables["User::UserId"].Value.ToString();
string Password = Dts.Variables["User::Password"].Value.ToString();
OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder();
builder["Provider"] = Provider;
builder["Data Source"] = ServerName;
builder["Initial Catalog"] = Catalog;
builder["User ID"] = UserId;
builder["Password"] = Password;
OleDbConnection connection = new OleDbConnection(builder.ConnectionString);
try
{
connection.Open();
}
catch
{
IsValid = false;
}
if (IsValid == true)
{
Dts.Variables["User::ConnString"].Value = builder.ConnectionString;
Dts.TaskResult = (int)ScriptResults.Success;
}
if (IsValid == false)
{
Dts.Events.FireError(0, "Connection Error", "Error initialising connection to server: " + ServerName, String.Empty, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
}
}