System.Data.SqlClient.SqlException 超时时间已到
来源:互联网 发布:石家庄勒泰鸿搜网络 编辑:程序博客网 时间:2024/06/05 10:07
错误信息:
有关调用实时(JIT)调试而不是此对话框的详细信息,请参见此消息的结尾。************** 异常文本 **************System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Timeout 时间已到。在操作完成之前超时时间已过或服务器未响应。 (错误详细信息等于 很可能由 IncludeExceptionDetailInFaults=true 创建的 ExceptionDetail,其值为:System.Data.SqlClient.SqlException: Timeout 时间已到。在操作完成之前超时时间已过或服务器未响应。在 System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()在 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)在 System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async)在 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)在 System.Data.SqlClient.SqlCommand.ExecuteNonQuery()在 Microsoft.Practices.EnterpriseLibrary.Data.Database.DoExecuteNonQuery(DbCommand command)在 Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteNonQuery(DbCommand command)************** 已加载的程序集 **************mscorlib程序集版本:4.0.0.0Win32 版本:4.0.30319.18444 built by: FX451RTMGDR基本代码:file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll----------------------------------------
错误信息或为:
System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. (错误详细信息等于 很可能由 IncludeExceptionDetailInFaults=true 创建的 ExceptionDetail,其值为:System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() 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, RunB...)。Server stack trace: 在 System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter) 在 System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) 在 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) 在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
解决方案:
System.Data.Common.DbCommand sqlStringCommand = this.db.GetSqlStringCommand(SQL);sqlStringCommand.CommandTimeout = 1800000;this.db.ExecuteNonQuery(sqlStringCommand);
修改Command的TimeOut属性未合适的时间即可。
小注:
也许你会说,我在连接字符串中已经 设置了 Connect Timeout=80000 ,并且数据库中超时连接也是设置的值是一个很大的值。为啥到了30秒,仍然超时了呢??
这是因为:
你的设置并没有问题,是你混淆了 SqlCommand.CommandTimeout 和 SqlConnection.ConnectionTimeout 这两个的区别了。
你的连接字符串中的超时只是设置的 SqlConnection.ConnectionTimeout 的值,而不是设置的 SqlCommand.CommandTimeout 的值。
SqlHelper 中并没有 SqlCommand.CommandTimeout 的相关设置。需要你自己设置。
下面是两个的比较:
SqlCommand.CommandTimeout
获取或设置在终止执行命令的尝试并生成错误之前的等待时间。
等待命令执行的时间(以秒为单位)。默认为 30 秒。
SqlConnection.ConnectionTimeout
获取在尝试建立连接时终止尝试并生成错误之前所等待的时间。
等待连接打开的时间(以秒为单位)。默认值为 15 秒。
小注部分参考:点击打开链接
0 0
- System.Data.SqlClient.SqlException 超时时间已到
- System.Data.SqlClient.SqlException (0x80131904): Timeout 时间已到
- System.Data.SqlClient.SqlException: 已超过了锁请求超时时段
- 未处理 System.Data.SqlClient.SqlException
- 超时时间已到。在操作完成之前超时时间已过或服务器未响应。 (.Net SqlClient Data Provider)
- 超时时间已到。在操作完成之前超时时间已过或服务器未响应。 (.Net SqlClient Data Provider)
- 超时时间已到。在操作完成之前超时时间已过或服务器未响应。 (.Net SqlClient Data Provider)
- Timeout 时间已到。在操作完成之前超时时间已过或服务器未响应。 (.Net SqlClient Data Provider)
- asp.net中遇到这样的异常:System.Data.SqlClient.SqlException: 将截断字符串或二进制数据。语句已终止。
- System.Data.SqlClient.SqlException: 必须声明变量 '@ImageUrl'。
- System.Data.SqlClient.SqlException 关键字 table 附近有语法错误。
- System.Data.SqlClient.SqlException: 将截断字符串或二进制数据
- System.Data.SqlClient.SqlException: Login failed for user
- IIS出现"System.Data.SqlClient.SqlException"时的解决办法
- System.Data.SqlClient.SqlException: 用户 'sa' 登录失败。
- “System.Data.SqlClient.SqlException”类型的未经处理
- System.Data.SqlClient.SqlException: 用户 'IIS APPPOOL\y3' 登录失败
- System.Data.SqlClient.SqlException: 从 datetime2 数据类型到 datetime 数据类型的转换产生一个超出范围的值
- ios RSA加密解密一些相关问题
- 互联网行业应届待遇十一档2014
- 使用HAProxy实现Percona XtraDB Cluster的负载均衡
- 移动端H5页面之iphone6的适配
- BZOJ1296【动态规划】
- System.Data.SqlClient.SqlException 超时时间已到
- 【总结】性能调优:CPU消耗分析
- IOS AutoLayout 布局 6个需求实现
- 构造函数 析构函数
- jQuery包装集方法总结
- linux下搭建FTP
- org.hibernate.PersistentObjectException: detached entity passed to persist
- iOS 关于枚举的使用
- linux socket编程相关问题