9

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

3 Answers 3

10

Try server.ConnectionContext.StatementTimeout

Sign up to request clarification or add additional context in comments.

Comments

8

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.

Comments

1

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

how to set the query timeout from SQL connection string

2 Comments

i know how to set commandtimeout with sqlcommand.. but i don't know how to assign that command to Microsoft.SqlServer.Management.Smo.Server
did you try to set ConnectTimeOut in ServerConnection, msdn.microsoft.com/en-us/library/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.