So, I am coding it as below,
sqlcommand.connection.close(); sqlcommand = null;
Now, Visual Studio is giving me a warning as it is an unnecessary assignment at sqlcommand = null. Kindly suggest.
So, I am coding it as below,
sqlcommand.connection.close(); sqlcommand = null;
Now, Visual Studio is giving me a warning as it is an unnecessary assignment at sqlcommand = null. Kindly suggest.
If you dont want to care about closing of connections and disposing these objects - best practice should be using
using (SqlConnection myConnection = new SqlConnection(connectionString))
{
myConnection.Open();
using (SqlCommand myCommand = new SqlCommand(command, myConnection))
{
}
}