Why can't I open connection when I use "using" code?
Posted on 2008-11-18
If I use the following code, in debug mode, I don't get error but the connection state stays "closed" even thought connection.Ope() is executed no problem.
using (connection = new SqlConnection(connectionString))
cmd = new SqlCommand(commandText, connection);
When i use the following code then there is no problem with connection not opened. Why is that so?
SqlConnection connection = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(commandText, connection);