【发布时间】:2014-08-27 07:27:37
【问题描述】:
我们如何将CommandTimeout设置为我们类中的一个属性,设置后它将在DAL中全部生效
using (SqlCommand command = conn.CreateCommand())
{
command.CommandTimeout = 60; //I need to make this globally. so all my timeout will have a 60 second
}
我也这样做了,但没有运气
public class Test : IDbCommand
{
public void DoSomething()
{
CommandTimeout = 10;
using (var sqlcon = new SqlConnection("Server=Server2;Database=;Trusted_Connection=true"))
{
using (var sqlcom = sqlcon.CreateCommand())
{
}
}
}
int _cto;
public int CommandTimeout
{
get
{
return _cto;
}
set
{
_cto = value;
}
}
【问题讨论】:
标签: c# asp.net .net sqlcommand