I'm getting the error, "The connection was not closed. The connection's current state is open." when executing the conn.Open(); command in the block below in a C# script task in my SSIS package. In Googling, I've seen other people saying that this may result from a try / catch not leading to the conn.Close();, but shouldn't "using" dispose the connection for me when it's finished?
bool fileRecordExists;
using (SqlConnection conn = (SqlConnection)Dts.Connections["connectionName"].AcquireConnection(Dts.Transaction))
{
SqlCommand sqlCmd = new SqlCommand(queryString, conn);
conn.Open();
fileRecordExists = (int)sqlCmd.ExecuteScalar() > 0 ? true : false;
}