使用 SMO 还原数据库时 SQL Server 超时 [英] SQL Server timeout while restoring databases with SMO
问题描述
我有一个 .NET 应用程序,我在其中使用 SMO 还原了许多数据库.连接字符串中的超时设置设为 0(无限制).大多数数据库恢复良好,除了有时在恢复时超时的一个数据库.它的大小接近3 GB.这个问题有什么解决方法吗?是否有我缺少的设置.我正在使用 DatabaseRestore 对象来恢复数据库.谢谢!
I have a .NET application where I restore a number of databases using SMO. The timeout setting in the connection string is set to 0 (unlimited). Most databases restore fine, except one databases that sometimes times out on the restore. The size of it approaches 3 GB. Are there any workarounds for this problem? Is there a setting I am missing. I am using DatabaseRestore object to restore the database. Thanks!
推荐答案
SMO 有两种超时设置 - 一种是 ConnectionTimeOut 设置,另一种是 StatementTimeOut 设置 - 您需要确保设置正确: http://social.msdn.microsoft.com/Forums/en-US/sqldisasterrecovery/thread/b4000547-7a48-4bda-9a68-ac646259e7d2/
There are two timeout settings for SMO - one is the ConnectionTimeOut settings, and the other is the StatementTimeOut setting - you need to make sure you are setting the right one: http://social.msdn.microsoft.com/Forums/en-US/sqldisasterrecovery/thread/b4000547-7a48-4bda-9a68-ac646259e7d2/
这是另一个问题,解决了他们的问题:SMO ConnectionContext.StatementTimeout设置被忽略
This is another question with a specific issue that resolved their problem: SMO ConnectionContext.StatementTimeout setting is ignored
希望这有帮助...
此外,还有一个 poweshell 脚本据说"适用于大型数据库.http://devio.wordpress.com/category/automssqlbackup/
Also, there is a poweshell script that 'supposedly' works well for large databases.. http://devio.wordpress.com/category/automssqlbackup/
这篇关于使用 SMO 还原数据库时 SQL Server 超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!