Connection timeout in SMO ServerConnection

Connection timeout in SMO

 

回答1

Apparently ServerConnection also has a statement timeout. SMO is full of these hidden timeouts. Including SQLBulkCopy. However, thanks to @Derek for pointing this out. The answer is you have to set the StatementTimeout = 0. I am testing this now but it appears to be the answer.

How to set CommandTimeout

http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.common.serverconnection.statementtimeout.aspx

 

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

 

 回答

Try server.ConnectionContext.StatementTimeout

 

posted @ 2022-05-07 10:03  ChuckLu  阅读(58)  评论(0)    收藏  举报