Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Timeout while reading data from database

Timeout while reading data from database

Scheduled Pinned Locked Moved Database
databasequestionsharepointsysadminhelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Muhammad Ahmed 0
    wrote on last edited by
    #1

    I am getting following exception in the code below 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 Ahmed

    Ahmed

    V P 2 Replies Last reply
    0
    • M Muhammad Ahmed 0

      I am getting following exception in the code below 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 Ahmed

      Ahmed

      V Offline
      V Offline
      vimal_yet
      wrote on last edited by
      #2

      U can Set ur own time for the connection and try.....

      If U Get Errors U Will Learn If U Don't Get Errors U Have Learnt

      1 Reply Last reply
      0
      • M Muhammad Ahmed 0

        I am getting following exception in the code below 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 Ahmed

        Ahmed

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        I would suspect that your problem is more to do with the connection timeout you are using in your connection string.

        Deja View - the feeling that you've seen this post before.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups