asp.net – 如何在web.config中增加执行sql查询的时间
|
当我在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 – Orchard CMS如何进行日志记录?
- asp.net-mvc – Html.BeginForm的默认区域是否始终是ASP.NE
- 如何在ASP.NET MVC网站上执行定期工作?
- 在asp.net中将产品信息存储在购物车中的理想方式
- asp.net-mvc – 你如何指定在列表框中显示多少项目(高度)
- ASP.NET MVC 3 – Ajax.BeginForm vs jQuery Form Plugin
- asp.net – 如何在.net中读取Elastic Beanstalk环境属性?
- asp.net-mvc – VS2012 ProjectTypeGuids在安装ASP.NET和We
- asp.net – 如何使用AntiXss Library正确清理内容?
- asp.net-mvc – 使用MVC和ASP.Net Core重写动态URL
- ASP.NET:web.config在哪里/如何缓存?
- asp.net – 使用UpdatePanel的CollectionPager问
- asp.net-mvc – Ninject和连接字符串
- iis – 如何通过预编译ASP.NET站点来确定性能改进
- asp.net-mvc – MVC 3 – Razor – 从模型打印值
- asp.net-web-api – Web API / MVC 6中的安全JSO
- 集成ASP.NET身份的最佳做法 – 它们是否存在?
- asp.net-mvc – 在ASP.NET MVC中禁用布局?
- asp.net-mvc – HttpContext中需要什么来允许For
- asp.net-mvc-3 – 具有MVC属性的IoC / DI
