asp.net – 如何在web.config中增加执行sql查询的时间
发布时间:2020-12-16 00:15:46 所属栏目:asp.Net 来源:网络整理
导读:当我在Web应用程序中运行查询时,我得到一个空值. SQL Management Studio中直接相同的查询返回结果. 我认为问题是暂停.如何在Web应用程序中增加执行查询的时间?在我的web.config:connectionstring中,没有超时代码.如果我在那里选择超时,会影响我系统的其他
当我在Web应用程序中运行查询时,我得到一个空值. SQL Management Studio中直接相同的查询返回结果.
我认为问题是暂停.如何在Web应用程序中增加执行查询的时间?在我的web.config:connectionstring中,没有超时代码.如果我在那里选择超时,会影响我系统的其他部分吗? 解决方法
你可以做一件事.
>在AppSettings.config中(如果不存在则创建一个),创建一个键值对. 喜欢:- <appSettings> <add key="SqlCommandTimeOut" value="240"/> </appSettings> 在代码中 – > command.CommandTimeout = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SqlCommandTimeOut"]); 应该这样做. 注意:- 例:- SqlCommand cmd = new SqlCommand(completequery); cmd.CommandTimeout = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SqlCommandTimeOut"]); SqlConnection con = new SqlConnection(sqlConnectionString); SqlDataAdapter adapter = new SqlDataAdapter(); con.Open(); adapter.SelectCommand = new SqlCommand(completequery,con); adapter.Fill(ds); con.Close(); 代替 DataSet ds = new DataSet(); ds = SqlHelper.ExecuteDataset(sqlConnectionString,CommandType.Text,completequery); 更新:另请参阅下面的@Triynko答案.检查一下也很重要. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 仅为匿名配置ASP.NET缓存?
- asp.net-mvc-4 – 从数据库上传模型时丢失dataAnottation
- asp.net-mvc – ASP.NET MVC可以在视图中使用接口作为模型吗
- asp.net – 在Global.asax方法中将与Autofac注册的组件的相
- asp.net-mvc – ASP.NET MVC依赖注入Unity与WCF服务 – 工作
- asp.net-mvc – ASP.NET MVC:让API控制器操作同时返回View
- asp.net-mvc-3 – 了解网站是否在MVC中编写的技巧?
- asp.net类序列化生成xml文件实例详解
- ..net学习群
- 更改ASP.NET XHTML渲染模式
推荐文章
站长推荐
- asp.net-mvc – 在IIS Express上设置SMTP
- asp.net – 多个域的集成Windows身份验证
- asp.net – Silverlight调试期间的Web服务超时
- asp.net-mvc – ASP.NET MVC Ajax.BeginForm不起
- Jquery 组合form元素为json格式,asp.net反序列化
- ASP.NET MVC null模型传递给控制器??动作
- asp.net-mvc – 如何在ASP.net MVC中限制对控制器
- asp.net-mvc – Dotlesscss @import语句:找不到
- ASP.Net:将客户端onClick添加到GridView中的Hyp
- asp.net – 如何在不使用bin目录的情况下加载卸载
热点阅读