错误提示:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
存储过程oa_YTWFHT 在数据查询分析器执行速度挺快的
            private void funNnd()
            {
                string tReturn = "";
                string sheetID = this.SheetNo;
                string sqlHRConnectionString = ConfigurationManager.ConnectionStrings["OASqlServer"].ConnectionString;
                SqlConnection con = new SqlConnection(sqlHRConnectionString);
                con.Open();
                string strSql = "exec dbo.oa_YTWFHT '" + sheetID + "'";
                SqlDataAdapter AD = new SqlDataAdapter(strSql, con);
                DataSet ds = new DataSet();
                AD.Fill(ds);
                con.Close();
                tReturn = ds.Tables[0].Rows[0][0].ToString();
            }create PROC [dbo].[oa_YTWFHT](@sheetID varchar(80))
AS
DECLARE  @HEADa nvarchar(8)
DECLARE  @HEADb nvarchar(4)
DECLARE  @HEAD  nvarchar(12)
DECLARE  @MAXd  nvarchar(4)
BEGIN
select @HEADa = stuff(year(GETDATE()),1,0,'B00-') 
from wfht 
where wfht002 = @sheetID            --'1107050010'    
select @MAXd = max(wfht018)+1 
from wfht 
where wfht002 like '11%'        
select @HEADb = stuff(@MAXd,1,1,'-') 
from wfht 
where wfht002 = @sheetID
set @HEAD = @HEADa + @HEADb    
update wfht
set 
wfht003 = @HEAD
,wfht018 = @MAXd                
from 
wfht 
where wfht002 = @sheetID        
select 'OK'
END做如下修改将不会出错
create PROC [dbo].[oa_YTWFHT](@sheetID varchar(80))
AS
DECLARE  @HEADa nvarchar(8)
DECLARE  @HEADb nvarchar(4)
DECLARE  @HEAD  nvarchar(12)
DECLARE  @MAXd  nvarchar(4)
BEGIN        
select 'OK'
END

解决方案 »

  1.   

    这个是不是并发死锁了,,你下面这个没有执行update操作...所以不会报错..update和select你写在了同一个存储过程了..又用一段程序直接条用这个过程...建议用事务update提交以后在select看看行不...或是select * from table with(nolock) 能查出来可能就是死锁吧..
      

  2.   


    select @HEADa = stuff(year(GETDATE()),1,0,'B00-') 
    from wfht 
    where wfht002 = @sheetID            --'1107050010'    
    select @MAXd = max(wfht018)+1 
    from wfht 
    where wfht002 like '11%'        
    select @HEADb = stuff(@MAXd,1,1,'-') 
    from wfht 
    where wfht002 = @sheetID
    set @HEAD = @HEADa + @HEADb   --将这段求值的作成函数试试。
      

  3.   

    默认command  timeout 超时 是  30秒
    建议改长