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

 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!!!

 

仅供参考。

posted @ 2014-06-13 11:19  Genie in the bottle  阅读(259)  评论(0编辑  收藏  举报