一开始以为是数据库死锁造成的后来设置了数据库锁超时时间为2000毫秒但是还是会出现页面一直卡在那里,不知道为什么?sqlserver设置锁超时时间setlock_timeout2000select@@lock_timeout难道代码逻辑有问题?C#代码如下:[down.aspx]stringidString=Request.QueryString["id"]??string.Empty;intid=0;if(!int.TryParse(idString,outid)){return;}vardbeh=Common.DB.Factory.CreateDBEntityHelper();if(int.TryParse(idString,outid)){vardlh=newDownLinkHelper();stringdownlink=dlh.GetDownlink(id);if(!string.IsNullOrEmpty(downlink)){Response.Redirect(Server.UrlPathEncode(Server.UrlDecode(downlink)));}}[DownLinkHelper.cs]usingSystem;usingSystem.Collections;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Web;usingSystem.Web.Caching;//////DownLink的摘要说明///
publicclassDownLinkHelper{Common.DB.IDBEntityHelperdbh=Common.DB.Factory.CreateDBEntityHelper();publicstringGetDownlink(intval){varent=dbh.GetEntity("SoftID="+val);if(ent!=null){returnent.Address;}returnstring.Empty;}}usingSystem;usingSystem.Collections;usingSystem.Collections.Generic;usingSystem.Data;usingSystem.Data.Common;usingSystem.Data.SqlClient;//////SQLServerHandler的摘要说明///
publicclassDBHelper:IDBHelper{stringconnectionString;publicstringConnectionString{get{returnconnectionString;}set{connectionString=value;}}publicDBHelper(stringconnectionString){this.connectionString=connectionString;}publicDbCommandCreateCommand(){returnnewSqlCommand();}publicDbConnectionCreateConnection(){returnnewSqlConnection(connectionString);}publicDbParameterCreateParameter(stringname,objectvalue){DbParameterparameter=CreateParameter();parameter.ParameterName=name;parameter.Value=value;returnparameter;}publicDbParameterCreateParameter(stringname){DbParameterparameter=CreateParameter();parameter.ParameterName=name;returnparameter;}publicDbParameterCreateParameter(){returnnewSqlParameter();}publicTExecuteScalar(stringsql,paramsDbParameter[]parameters){using(DbConnectionconnection=CreateConnection()){DbCommandcmd=CreateCommand();cmd.Connection=connection;cmd.CommandText=sql;cmd.Parameters.AddRange(parameters);connection.Open();objecto=cmd.ExecuteScalar();connection.Close();return(T)Convert.ChangeType(o,typeof(T));}}publicDbDataReaderExecuteReader(stringsql,paramsDbParameter[]parameters){DbConnectionconnection=CreateConnection();DbCommandcmd=CreateCommand();cmd.Connection=connection;cmd.CommandText=sql;cmd.Parameters.AddRange(parameters);connection.Open();returncmd.ExecuteReader(CommandBehavior.CloseConnection);}publicintExecuteNoneQuery(stringsql,paramsDbParameter[]parameters){using(DbConnectionconnection=CreateConnection()){DbCommandcmd=CreateCommand();cmd.Connection=connection;cmd.CommandText=sql;cmd.Parameters.AddRange(parameters);connection.Open();intnum=cmd.ExecuteNonQuery();connection.Close();returnnum;}}publicListGetDataList(stringsql,paramsDbParameter[]parameters){Listlist=newList();using(DbDataReaderreader=ExecuteReader(sql,parameters)){while(reader.Read()){Hashtablehs=newHashtable();for(inti=0;i{hs[reader.GetName(i)]=reader.GetValue(i);}list.Add(hs);}reader.Close();reader.Dispose();}returnlist;}publicHashtableGetData(stringsql,paramsDbParameter[]parameters){Hashtablehs=null;using(DbDataReaderreader=ExecuteReader(sql,parameters)){while(reader.Read()){hs=newHashtable();for(inti=0;i{hs[reader.GetName(i)]=reader.GetValue(i);}}reader.Close();reader.Dispose();}returnhs;}}//////DbEntityHelper的摘要说明///
publicclassDBEntityHelper:IDBEntityHelper{IDBHelperdb=null;publicIDBHelperDBHelper{get{returndb;}set{db=value;}}publicDBEntityHelper(){}