Timeout Exception while closing db connection-Urgent.
Exception occurs when closing connection,
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
The SqlCommandTimeout is already set 0 as you can see in the code below,
When i search records for first time it works fine, but the exceptions start coming second time or third time onwards,..
Protected Overrides Sub DataPortal_Fetch(ByVal criteria As Object)
' Load object data from database.
Dim crit As criteria = DirectCast(criteria, criteria)
Dim con As New SqlConnection(DB())
// db string is something like
//"data source=hurst\SQL2000_SP4;initial catalog=MYDB_OOP_11;Connection Timeout=60;user=asd_user;password=asd_user;"
Dim cmd As New SqlCommand
con.Open()
Try
With cmd
.Connection = con
.CommandType = CommandType.StoredProcedure
.CommandTimeout = 0
' Set up and call appropriate stored procedure.
If crit.IsSimpleList Then
.CommandText = DBObject & "_info_simple_get"
With .Parameters
// some code for adding params for SP
End With
Else
.CommandText = DBObject & "_info_get"
With .Parameters
// adding param for Stored Procedure here
End With
End If
Dim dr As New SafeDataReader(.ExecuteReader)
Try
Me.Fetch(dr, crit.IsSimpleList)
// The fectch function loops for each read of datareader and creates a new object, passing it dr object, each object then reads its column from dr
Finally
dr.Close()
End Try
End With
Finally
con.Close() // I get exception here..on closing..
End Try
End Sub
Is it something because of improper use of DataReader ? or what is it, I really couldnt figure out, I have Tried using GC.collect() etc , but no use,
please help
Regrads,
Ahmed

