SqlCeTransactionInProgressException 类
在另一个事务进行期间尝试修改数据库时发生。
命名空间: System.Data.SqlServerCe
程序集: System.Data.SqlServerCe(在 system.data.sqlserverce.dll 中)
语法
声明
Public Class SqlCeTransactionInProgressException
Inherits SqlCeException
用法
Dim instance As SqlCeTransactionInProgressException
public class SqlCeTransactionInProgressException : SqlCeException
public ref class SqlCeTransactionInProgressException : public SqlCeException
public class SqlCeTransactionInProgressException extends SqlCeException
public class SqlCeTransactionInProgressException extends SqlCeException
不适用。
示例
Dim timeout As New TimeSpan(0, 0, 15) 'hours, minutes, seconds
Dim startTime As DateTime = DateTime.Now
While DateTime.Now - startTime < timeout
Try
Dim repl As New SqlCeReplication()
repl.InternetUrl = "https://www.adventure-works.com/sqlmobile/sqlcesa30.dll"
repl.Publisher = "myPublisher"
repl.PublisherDatabase = "AdventureWorks"
repl.PublisherSecurityMode = SecurityType.NTAuthentication
repl.Publication = "AdventureWorks"
repl.Subscriber = "Test"
repl.SubscriberConnectionString = "Data Source='MyDatabase.sdf';Password='';"
repl.Synchronize()
Catch exInProgress As SqlCeTransactionInProgressException
Thread.Sleep(3000)
GoTo ContinueWhile1
Catch exTimeout As SqlCeLockTimeoutException
' Add your own error-handling logic here
GoTo ContinueWhile1
Catch e As SqlCeException
MessageBox.Show(e.Message)
End Try
ContinueWhile1:
End While
TimeSpan timeout = new TimeSpan(0 /*hours*/, 0 /* minutes */ , 15 /*seconds*/);
DateTime startTime = DateTime.Now;
while (DateTime.Now - startTime < timeout)
{
try
{
SqlCeReplication repl = new SqlCeReplication();
repl.InternetUrl = "https://www.adventure-works.com/sqlmobile/sqlcesa30.dll";
repl.Publisher = "myPublisher";
repl.PublisherDatabase = "AdventureWorks";
repl.PublisherSecurityMode = SecurityType.NTAuthentication;
repl.Publication = "AdventureWorks";
repl.Subscriber = "Test";
repl.SubscriberConnectionString = "Data Source='MyDatabase.sdf';Password='';";
repl.Synchronize();
}
catch (SqlCeTransactionInProgressException)
{
Thread.Sleep(3000);
continue;
}
catch (SqlCeLockTimeoutException)
{
//add your own error-handling logic here
}
catch (SqlCeException e)
{
MessageBox.Show(e.Message);
}
}
继承层次结构
System.Object
System.Exception
System.SystemException
System.Data.SqlServerCe.SqlCeException
System.Data.SqlServerCe.SqlCeTransactionInProgressException
线程安全
此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。
平台
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
Windows Vista、Microsoft Windows XP SP2 和 Windows Server 2003 SP1 支持 Microsoft .NET Framework 3.0。
版本信息
.NET Framework
受以下版本支持:3.0
.NET Compact Framework
受以下版本支持:2.0
请参见
参考
SqlCeTransactionInProgressException 成员
System.Data.SqlServerCe 命名空间