How to install CommandTimeout

I am using Microsoft.SqlServer.Management.Smo .

My code is:

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

I want to set CommandTimeout for it, as is the case with regular SQLCommand

Please tell me how to set CommandTimeout for queries passing through Microsoft.SqlServer.Management.Smo.Server

+7
source share
3 answers
+8
source

You can set the command timeout using the SMO object, as shown below:

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

For more information about the SMO object command timeout, see this link .

+6
source

All Articles