Do you get a message or anything?
It might be you need to add a question mark to make the variable nullable.
SqlConnection? sc = null;
However, it would be better to assign the variable with the new instance instead of null. You can do that before the "try". But for even better code you should use
using
.
using (SqlConnection sc = new SqlConnection(...) )
{
...
}
This way
sc
is always cleaned up automatically.
Good luck!