How to set CommandTimeout
Asked Answered
T

3

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

Tirza answered 9/5, 2012 at 7:53 Comment(0)
G
10

Try server.ConnectionContext.StatementTimeout

Glint answered 9/5, 2012 at 8:0 Comment(0)
R
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.

Repeat answered 9/5, 2012 at 9:46 Comment(0)
D
1

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

how to set the query timeout from SQL connection string

Deportee answered 9/5, 2012 at 7:56 Comment(2)
i know how to set commandtimeout with sqlcommand.. but i don't know how to assign that command to Microsoft.SqlServer.Management.Smo.ServerTirza
did you try to set ConnectTimeOut in ServerConnection, msdn.microsoft.com/en-us/library/…Deportee

© 2022 - 2024 — McMap. All rights reserved.