I am rewriting a .NET 1.1 app to 4.0. This code compiles just fine, but I receive numerous warnings like:
"call System.IDispoable.Dispose on object 'sqlCmd' before all references to it are out of scope".
I also get that warning for da and results.
Is it really important that I clean that up? And how would I "dispose" of these? I thought the garbage collector does that for me.
Thank you for helping!
Public Function SelectTsql(ByVal qryString As String) As DataTable
Dim sqlCmd As SqlCommand
Dim da As SqlDataAdapter
Dim results As DataTable
sqlCmd = New SqlCommand
'.Transaction = transaction
.CommandTimeout = 240
.CommandText = qryString
If _sqlInSrvCnn1.State = ConnectionState.Open Then
.Connection = _sqlInSrvCnn1
.Connection = _sqlInSrvCnn2
.CommandType = CommandType.Text
da = New SqlDataAdapter(sqlCmd)
results = New DataTable
If results.Rows.Count > 0 Then