码迷,mamicode.com
首页 > 数据库 > 详细

Time Out 访问数据库超时处理 .NET

时间:2014-06-15 22:05:01      阅读:327      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   code   ext   color   

 1 using System.Reflection;
 2 
 3 using System.Data.SqlClient;
 4 
 5  
 6 
 7      
 8 
 9             TransactionSelectTableAdapter adapter = new TransactionSelectTableAdapter();
10 
11             Type adapterType = adapter.GetType();
12 
13             PropertyInfo commandProperty = adapterType.GetProperty("CommandCollection", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
14 
15             SqlCommand[] commandList = (SqlCommand[])commandProperty.GetValue(adapter, null);
16 
17             commandList[0].CommandTimeout = 3000;

也有同事之间改某个文件的属性,相对感觉欠优雅。

个人喜欢另一个同事教我的方法,如上。

 

对了,对于那些同事们教我的事,

感谢我的同事们,God bless you!!!

 

仅供参考。

Time Out 访问数据库超时处理 .NET,布布扣,bubuko.com

Time Out 访问数据库超时处理 .NET

标签:style   class   blog   code   ext   color   

原文地址:http://www.cnblogs.com/coderinprague/p/3785463.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!