【问题标题】:How to set CommandTimeout如何设置命令超时
【发布时间】:2012-05-17 17:25:26
【问题描述】:

我正在使用Microsoft.SqlServer.Management.Smo

我的代码:

Server server = new Server(new ServerConnection( new SqlConnection(ConnectionString));
server.ConnectionContext.ExecuteNonQuery(script);

我想为它设置CommandTimeout,就像我们使用普通的SQLCommand一样

请告诉我如何为通过Microsoft.SqlServer.Management.Smo.Server 运行的查询设置CommandTimeout

【问题讨论】:

    标签: c# smo sqlcommand command-timeout


    【解决方案1】:
    【解决方案2】:

    您可以使用 SMO 对象设置命令超时,如下所示:

    Server server = new Server(new ServerConnection(new SqlConnection(ConnectionString));
    server.ConnectionContext.StatementTimeout = 10800;
    server.ConnectionContext.ExecuteNonQuery(script);
    

    有关 SMO 对象命令超时的更多信息,请参阅此link

    【讨论】:

      【解决方案3】:

      【讨论】:

      • 我知道如何使用 sqlcommand 设置 commandtimeout.. 但我不知道如何将该命令分配给 Microsoft.SqlServer.Management.Smo.Server
      • 您是否尝试在ServerConnection中设置ConnectTimeOut,msdn.microsoft.com/en-us/library/…
      猜你喜欢
      • 2014-08-13
      • 1970-01-01
      • 1970-01-01
      • 2016-12-27
      • 2012-01-16
      • 1970-01-01
      • 1970-01-01
      • 2019-09-20
      • 1970-01-01
      相关资源
      最近更新 更多