title: SSIS Script Task Error
body: <p>I'm trying to get this <a href="https://stackoverflow.com/questions/15302274/ssis-looping-through-servers-and-handling-failed-logins">answer</a> working in my package, but I get the below error message on the first line.</p>
  
  <p><strong>Cannot implicitly convert type 'object' to 'string'. An explicit conversion exists (are you missing a cast?)</strong></p>
  
  <p>I also get a warning saying "ex" is declared but never used. </p>
  
  <p>Anyone know what I can do to fix this?</p>
  
  <pre><code>        string connString = Dts.Variables["User::SQLServer"].Value;
  
          try
          {
              using (OleDbConnection connection = new OleDbConnection())
              {
                  connection.ConnectionString = connString;
                  connection.Open();
              }
              Dts.Variables["User::DatabaseCanConnect"].Value = true;
          }
          catch (Exception ex)
          {
              Dts.Variables["User::DatabaseCanConnect"].Value = false;
          }
  
          Dts.TaskResult = (int)ScriptResults.Success;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/2BTtq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2BTtq.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/3P2Pm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3P2Pm.png" alt="enter image description here"></a></p>