Share via


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
type SqlCeTransactionInProgressException =  
    class
        inherit SqlCeException
    end
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/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);
            }
        }

継承階層

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

スレッド セーフ

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

関連項目

参照

SqlCeTransactionInProgressException メンバー

System.Data.SqlServerCe 名前空間