G
Guest
Hello,
I am just checking if VS2005/VB2005 automatically opens and closes
sqlConnections for you. I noticed that if I just invoke the connectin
conn = new SqlConnection
conn.ConnectionString = "..."
cmd.Connection = conn
....
dataAdapter.SelectCommand = cmd
dataAdapter.Fill(ds, "tbl1")
Console.Writeline(cmd.Connection.State.ToString)
'--the connection is always closed -- unless I specifically say conn.Open
I never say conn.Open or conn.Close or cmd.Connection.Close and I don't get
any Exceptions. I only get an exception if I say conn.Open without a
conn.Close and then try to re-open conn.Open - error says connection not
closed. So it looks like if I leave out conn.Open, then I don't need to
worry about conn.Close. Is this a feature of VS2005?
Thanks,
Rich
I am just checking if VS2005/VB2005 automatically opens and closes
sqlConnections for you. I noticed that if I just invoke the connectin
conn = new SqlConnection
conn.ConnectionString = "..."
cmd.Connection = conn
....
dataAdapter.SelectCommand = cmd
dataAdapter.Fill(ds, "tbl1")
Console.Writeline(cmd.Connection.State.ToString)
'--the connection is always closed -- unless I specifically say conn.Open
I never say conn.Open or conn.Close or cmd.Connection.Close and I don't get
any Exceptions. I only get an exception if I say conn.Open without a
conn.Close and then try to re-open conn.Open - error says connection not
closed. So it looks like if I leave out conn.Open, then I don't need to
worry about conn.Close. Is this a feature of VS2005?
Thanks,
Rich