Nothing. If
connection
is null, it will still throw an exception.
Try this:
if (connection != null && conection.State != ConnectionState.Closed)
{
conection.Close();
}
But better, use a
using
block around your connection creation so it is automatically closed and disposed when it goes out of scope.