如何设置CommandTimeout

Dr.*_*len 8 c# smo sqlcommand command-timeout

我在用 Microsoft.SqlServer.Management.Smo.

我的代码:

Server server = new Server(new ServerConnection( new SqlConnection(ConnectionString));
server.ConnectionContext.ExecuteNonQuery(script);
Run Code Online (Sandbox Code Playgroud)

我想像CommandTimeout平常那样设置它SQLCommand

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

Raj*_*esh 7

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

Server server = new Server(new ServerConnection(new SqlConnection(ConnectionString));
server.ConnectionContext.StatementTimeout = 10800;
server.ConnectionContext.ExecuteNonQuery(script);
Run Code Online (Sandbox Code Playgroud)

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