ConnectionRead (WrapperRead())Timeout expired

■环境说明:

数据库系统:Microsoft Server 2000 (Sp4)

操作系统:Microsoft Server 2003 (SP1)

开发环境:Microsoft  Visual Studio .net 2003

■代码

 1 None.gif        SqlCommand SqlComm = new SqlCommand();
 2 None.gif            try
 3 ExpandedBlockStart.gif ContractedBlock.gif             dot.gif{
 4 InBlock.gif                SqlComm.Connection = sqlConn;
 5 InBlock.gif                SqlComm.CommandText = p_ProcedureName;
 6 InBlock.gif                SqlComm.CommandType=CommandType.StoredProcedure ;
 7 InBlock.gif                SqlComm.ExecuteNonQuery();
 8 ExpandedBlockEnd.gif            }
 9 None.gif            catch (SqlException myException)
10 ExpandedBlockStart.gif ContractedBlock.gif             dot.gif{
11 InBlock.gif            for (int i=0; i < myException.Errors.Count; i++)
12 ExpandedSubBlockStart.gif ContractedSubBlock.gif             dot.gif{
13 InBlock.gif                errorMessages = "Index #" + i + "\n" +
14 InBlock.gif                    "Source: " + myException.Errors[i].Source + "\n" +
15 InBlock.gif                    "Number: " + myException.Errors[i].Number.ToString() + "\n" +
16 InBlock.gif                    "State: " + myException.Errors[i].State.ToString() + "\n" +
17 InBlock.gif                    "Class: " + myException.Errors[i].Class.ToString() + "\n" +
18 InBlock.gif                    "Server: " + myException.Errors[i].Server + "\n" +
19 InBlock.gif                    "Message: " + myException.Errors[i].Message + "\n" +
20 InBlock.gif                    "Procedure: " + myException.Errors[i].Procedure + "\n" +
21 InBlock.gif                    "LineNumber: " + myException.Errors[i].LineNumber.ToString();
22 ExpandedSubBlockEnd.gif            }
23 ExpandedBlockEnd.gif            }
24 None.gif


■说明
执行存储过程p_ProcedureName的过程中,截取到SqlException异常,以上内容如下:

ERROR: Index #0
Source: .Net SqlClient Data Provider
Number: -2
State: 0
Class: 10
Server: DatabaseServer
Message: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
Procedure: ConnectionRead (WrapperRead()).
LineNumber: 0

究竟原因为何,最终未能调查出来。
最后换了另一种处理方式,将存储过程放到job中执行。然后代码中通过执行存储过程sp_start_job来启动作业,间接执行自定义的存储过程。避免发生该异常。
如果有更好的方法解决该问题,还请赐教!先行谢过!

 1 None.gif                  // 执行启动作业的存储过程
 2 ExpandedBlockStart.gifContractedBlock.gif                 SqlParameter[] spParams  =   dot.gif {
 3InBlock.gif                                              new SqlParameter("@job_name",SqlDbType.NVarChar,128)
 4ExpandedBlockEnd.gif                                          }
;
 5 None.gif 
 6 None.gif                 // 作业名称
 7 None.gif                 spParams[ 0 ].Value  =  p_ProcedureName;
 8 None.gif
 9 None.gif                SqlCommand objSqlCommand  =   new  SqlCommand();
10 None.gif                objSqlCommand.Connection = objSqlConnection;
11 None.gif                objSqlCommand.CommandType = CommandType.StoredProcedure;
12 None.gif                objSqlCommand.CommandText = " sp_start_job " ;
13 None.gif                 for ( int  i = 0  ;i < spParams.Length;i ++ )
14 ExpandedBlockStart.gifContractedBlock.gif                 dot.gif {
15InBlock.gif                    objSqlCommand.Parameters.Add(spParams[i]);
16ExpandedBlockEnd.gif                }

17 None.gif
18 None.gif                objSqlCommand.ExecuteNonQuery();


 

posted on 2006-04-11 17:02 半空 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/zhangwenbo/archive/2006/04/11/te.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值