G
Guest
I have the following VB.NET code:
....
Dim cmd As New SqlCommand
Try
With cmd
.Connection = New SqlConnection(...)
.CommandText = "sp..."
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@year", SqlDbType.Int).Value = intYear
.Parameters.Add("@quarter", SqlDbType.Int).Value = intQuarter
cmd.Connection.Open()
cmd.ExecuteNonQuery()
End With
Finally
If Not cmd Is Nothing Then cmd.Dispose()
End Try
....
My question is, does the connection object get disposed and closed with the
SqlCommand's dispose?
I do the same kind of thing, except with a SqlDataAdapter object. Does the
connection object get disposed and closed with the SqlDataAdapter's dispose?
Thanks,
J.J.
....
Dim cmd As New SqlCommand
Try
With cmd
.Connection = New SqlConnection(...)
.CommandText = "sp..."
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@year", SqlDbType.Int).Value = intYear
.Parameters.Add("@quarter", SqlDbType.Int).Value = intQuarter
cmd.Connection.Open()
cmd.ExecuteNonQuery()
End With
Finally
If Not cmd Is Nothing Then cmd.Dispose()
End Try
....
My question is, does the connection object get disposed and closed with the
SqlCommand's dispose?
I do the same kind of thing, except with a SqlDataAdapter object. Does the
connection object get disposed and closed with the SqlDataAdapter's dispose?
Thanks,
J.J.