Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set CommandTimeout

I am using Microsoft.SqlServer.Management.Smo.

My Code:

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

I want to set CommandTimeout for it like we do with normal SQLCommand

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

like image 592
Dr. Rajesh Rolen Avatar asked May 09 '12 07:05

Dr. Rajesh Rolen


3 Answers

Try server.ConnectionContext.StatementTimeout

like image 152
Strillo Avatar answered Oct 24 '22 11:10

Strillo


You can set 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 on SMO object command timeout refer this link.

like image 20
Rajesh Avatar answered Oct 24 '22 12:10

Rajesh


http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout.aspx

how to set the query timeout from SQL connection string

like image 26
Tilak Avatar answered Oct 24 '22 12:10

Tilak