How to set CommandTimeout

你。 提交于 2020-01-13 08:29:07

问题


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


回答1:


Try server.ConnectionContext.StatementTimeout




回答2:


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.




回答3:


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

how to set the query timeout from SQL connection string



来源:https://stackoverflow.com/questions/10511984/how-to-set-commandtimeout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!