共用方式為


SqlCeTransactionInProgressException Class

當其他交易進行中的同時嘗試修改資料庫時發生。

命名空間: System.Data.SqlServerCe
組件: System.Data.SqlServerCe (在 system.data.sqlserverce.dll)

語法

'宣告
Public Class SqlCeTransactionInProgressException
    Inherits SqlCeException
public class SqlCeTransactionInProgressException : SqlCeException
public ref class SqlCeTransactionInProgressException : public SqlCeException
public class SqlCeTransactionInProgressException extends SqlCeException
public class SqlCeTransactionInProgressException extends SqlCeException

繼承階層

System.Object
   System.Exception
     System.SystemException
       System.Data.SqlServerCe.SqlCeException
        System.Data.SqlServerCe.SqlCeTransactionInProgressException

範例

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/sqlcesa35.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/sqlcesa35.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);
    }
}

執行緒安全性

任何公用靜態 (共用 在 Microsoft Visual Basic) 此型別的成員具備執行緒安全。不保證任何執行個體成員安全執行緒。

平台

開發平台

Windows Vista, Windows Mobile 5.0, Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Mobile 2003 for Pocket PC, Windows CE 5.0
版本資訊
.NET Framework 及 NET Compact Framework
支援於 3.5
.NET Framework
支援於 3.0
.NET Compact Framework 及 .Net Framework
支援於 2.0

另請參閱

參考

SqlCeTransactionInProgressException Members
System.Data.SqlServerCe Namespace