您的位置:首页 > 博客中心 > 数据库 >

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

时间:2022-03-10 17:36

 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

热门排行

今日推荐

热门手游