Results 1 to 2 of 2

Thread: Timeout Expired Error ..

  1. #1

    Thread Starter
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456

    Timeout Expired Error ..

    VB Code:
    1. Public Overloads Function ExecuteStoredProcedure(ByVal page As Integer, ByVal pageSize As Integer, _
    2.                                                          ByRef recordCount As Long, ByVal connection As System.Data.SqlClient.SqlConnection, ByVal storedProcedureName As String, _
    3.                                                          ByRef returnObject As DataSet, ByVal sqlParameters() As SqlParameter, _
    4.                                                          Optional ByVal includeReturnValue As Boolean = True, _
    5.                                                          Optional ByVal mustCloseConnection As Boolean = False) As Hashtable
    6.             Dim i, j As Int16
    7.             Dim dataAdapter As New System.Data.SqlClient.SqlDataAdapter
    8.             Dim returnValues As New Hashtable(New CaseInsensitiveHashCodeProvider, New CaseInsensitiveComparer)
    9.  
    10.             Try
    11.                 OpenConnection(connection)
    12.  
    13.                 Dim command As New System.Data.SqlClient.SqlCommand(storedProcedureName, connection)
    14.  
    15.                 [B]command.CommandTimeout = 0                [/B]
    16.                 command.CommandType = CommandType.StoredProcedure
    17.  
    18.                 If Not (sqlParameters Is Nothing) Then
    19.                     For i = 0 To CType(sqlParameters.Length - 1, Short)
    20.                         command.Parameters.Add(sqlParameters(i))
    21.                     Next
    22.                 End If
    23.  
    24.                 If includeReturnValue Then
    25.                     Dim returnValue As New SqlParameter("@RETURN_VALUE", SqlDbType.BigInt)
    26.                     returnValue.Direction = ParameterDirection.ReturnValue
    27.                     command.Parameters.Add(returnValue)
    28.                 End If
    29.  
    30.                 dataAdapter.SelectCommand = command
    31.  
    32.                 If TypeName(returnObject).ToUpper = ("DataSet").ToUpper Then
    33.                     recordCount = dataAdapter.Fill(CType(returnObject, DataSet), pageSize * (page - 1), pageSize, dataAdapter.DefaultSourceTableName)
    34.                     If CType(returnObject, DataSet).Tables(0).Rows.Count = 0 Then
    35.                         recordCount = 0
    36.                     Else
    37.                         recordCount = CLng(CType(returnObject, DataSet).Tables(0).Rows(0)("Paging_Rec_Cnt").ToString)
    38.                     End If
    39.                     returnValues.Add("dataAdapter", dataAdapter)
    40.                 Else
    41.                     command.ExecuteNonQuery()
    42.                     returnObject = Nothing
    43.                 End If
    44.  
    45.                 returnValues.Add("Error", 0)
    46.  
    47.                 If includeReturnValue Then returnValues.Add("@RETURN_VALUE", command.Parameters("@RETURN_VALUE").Value)
    48.  
    49.                 Dim sqlParameter As SqlParameter
    50.  
    51.                 For Each sqlParameter In command.Parameters
    52.                     If sqlParameter.Direction = ParameterDirection.InputOutput Or sqlParameter.Direction = ParameterDirection.Output Then
    53.                         returnValues.Add(sqlParameter.ParameterName.ToString, sqlParameter.Value)
    54.                     End If
    55.                 Next
    56.  
    57.                 command.Dispose()
    58.                 Return (returnValues)
    59.  
    60.             Catch sqlex As SqlException
    61.  
    62.                 returnValues.Add("Error", -1)
    63.                 LogException(sqlex)
    64.                 Return (returnValues)
    65.                 Throw sqlex
    66.             Catch ex As Exception
    67.  
    68.                 returnValues.Add("Error", -1)
    69.                 LogException(ex)
    70.                 Return (returnValues)
    71.                 Throw ex
    72.             Finally
    73.                 dataAdapter.Dispose()
    74.                 If mustCloseConnection Then CloseConnection(connection)
    75.             End Try
    76.         End Function

    This is one of the methods in my Data Access Component. It works fine if I remove the CommandTimeout = 0 Line, however, if I do not, then it gives me "Timeout Expired" error even though it is suppose to wait forever for server to return with the data ?? Anybody knows whats going on here ??
    Last edited by techyspecy; Mar 3rd, 2005 at 08:13 AM.

  2. #2

    Thread Starter
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456

    Re: Timeout Expired Error ..


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width