超时到期.在完成操作或服务器完成之前已经过的超时期未响应

  • 本文关键字:超时 经过 响应 操作 服务器 timeout
  • 更新时间 :
  • 英文 :


所以我有这个功能

Public Function getDataSetonDataTable(ByVal query As String, ByVal    sDatabaseConnection As String) As DataTable
    Dim dsRecordset As New DataSet
    Dim dtReturn As DataTable
    Try
        open(sDatabaseConnection)
        oConn.Open()
    Catch ex As Exception
        log.infoError(ex, "GET DATA SETON DATA PART 1 ON cDatabase.vb")
        Return Nothing
    End Try
    Try
        createLog("Q || " & query)
        dsRecordset = oDatabase.ExecuteDataSet(System.Data.CommandType.Text, query)
        dtReturn = dsRecordset.Tables(0)
    Catch ex As Exception
        If ex.Message.ToString = "Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding." Then
            Try
                createLog("Query : " & query)
                dsRecordset = oDatabase.ExecuteDataSet(System.Data.CommandType.Text, query)
                dtReturn = dsRecordset.Tables(0)
            Catch ex2 As Exception
                log.infoError(ex, "GET DATA SETON DATA PART 2 ON cDatabase.vb")
                dtReturn = Nothing
                ErrorMessage = ex2.Message.ToString
                MessageBox.Show(ErrorMessage, "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
            Finally
                oConn.Close()
            End Try
            Return dtReturn
        End If
        dtReturn = Nothing
        ErrorMessage = ex.Message.ToString
        MessageBox.Show(ErrorMessage, "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
    Finally
        oConn.Close()
    End Try
    Return dtReturn
End Function

这是数据重新调整Codeline

dsRecordset = oDatabase.ExecuteDataSet(System.Data.CommandType.Text, query)

但是,如果它执行复杂的查询,则恰好60秒后将其访问此例外

System.Data.SqlClient.SqlException was caught
  Class=11
  ErrorCode=-2146232060
  LineNumber=0
  Message="Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding."
  Number=-2
  Procedure=""
  Server="KF-DC1DB01"
  Source=".Net SqlClient Data Provider"
  State=0
  StackTrace:
       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
       at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
       at System.Data.SqlClient.SqlDataReader.get_MetaData()
       at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
       at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
       at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
       at Microsoft.Practices.EnterpriseLibrary.Data.Database.DoLoadDataSet(DbCommand command, DataSet dataSet, String[] tableNames)
       at Microsoft.Practices.EnterpriseLibrary.Data.Database.LoadDataSet(DbCommand command, DataSet dataSet, String[] tableNames)
       at Microsoft.Practices.EnterpriseLibrary.Data.Database.LoadDataSet(DbCommand command, DataSet dataSet, String tableName)
       at Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteDataSet(DbCommand command)
       at Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteDataSet(CommandType commandType, String commandText)
       at Database.cDatabase.getDataSetonDataTable(String query, String sDatabaseConnection) in D:My ProjectClassLibraryKalbeDatabasecDatabase.vb:line 117

如何将超时设置为更长的时间?
我在Visual Studio 2005中使用vb.net
预先感谢。

灵感来自enterPriseLibrary的sql commandtimeout设置的启发,我将查询分配给system.data.data.common.dbcommand acmand acmand acmant eartiaut,分配了一个超时,并使用dbcommand command command command command command valibal acmand acmand comp。

相关内容

  • 没有找到相关文章

最新更新