Share via


SqlCeLockTimeoutException 类

如果已经达到锁超时,则会引发此异常。

继承层次结构

System.Object
  System.Exception
    System.SystemException
      System.Runtime.InteropServices.ExternalException
        System.Data.Common.DbException
          System.Data.SqlServerCe.SqlCeException
            System.Data.SqlServerCe.SqlCeLockTimeoutException

命名空间:  System.Data.SqlServerCe
程序集:  System.Data.SqlServerCe(在 System.Data.SqlServerCe.dll 中)

语法

声明
<SerializableAttribute> _
Public Class SqlCeLockTimeoutException _
    Inherits SqlCeException
用法
Dim instance As SqlCeLockTimeoutException
[SerializableAttribute]
public class SqlCeLockTimeoutException : SqlCeException
[SerializableAttribute]
public ref class SqlCeLockTimeoutException : public SqlCeException
[<SerializableAttribute>]
type SqlCeLockTimeoutException =  
    class
        inherit SqlCeException
    end
public class SqlCeLockTimeoutException extends SqlCeException

SqlCeLockTimeoutException 类型公开以下成员。

构造函数

  名称 说明
受保护方法 SqlCeLockTimeoutException 有助于序列化的构造函数。

页首

属性

  名称 说明
公共属性 Data (继承自 Exception
公共属性 ErrorCode (继承自 ExternalException
公共属性 Errors 获取一个或多个 SqlCeError 对象的集合,这些对象包含有关用于 SQL Server Compact 的 .NET Compact Framework 数据提供程序生成的异常的详细信息。 (继承自 SqlCeException
公共属性 HelpLink (继承自 Exception
公共属性 HResult 获取异常的 HRESULT 值。此值与异常的 SqlCeErrorCollection 中的第一个 SqlCeError 实例的 HResult 值相同。 (继承自 SqlCeException
公共属性 InnerException (继承自 Exception
公共属性 Message 获取描述此异常的 SqlCeErrorCollection 中的第一个 SqlCeError 实例的文本。 (继承自 SqlCeException
公共属性 NativeError 获取 SqlCeErrorCollection 中第一个 SqlCeError 的本机错误号。有关该错误的详细信息,请参阅 SQL Server Compact 联机丛书的“疑难解答”一节中的“SQL Server Compact 错误”主题。 (继承自 SqlCeException
公共属性 Source 获取生成错误的 OLE DB 提供程序的名称。 (继承自 SqlCeException
公共属性 StackTrace (继承自 Exception
公共属性 TargetSite (继承自 Exception

页首

方法

  名称 说明
公共方法 Equals (继承自 Object
受保护方法 Finalize (继承自 Object
公共方法 GetBaseException (继承自 Exception
公共方法 GetHashCode (继承自 Object
公共方法 GetObjectData 安全关键。 使用序列化对象所需的数据填充 SerializationInfo。 (覆盖 SqlCeException.GetObjectData(SerializationInfo, StreamingContext)。)
公共方法 GetType (继承自 Exception
受保护方法 MemberwiseClone (继承自 Object
公共方法 ToString (继承自 Exception

页首

注释

有关详细信息,请参阅 SQL Server Compact 联机丛书中的“锁定 (SQL Server Compact)”主题。

示例

        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 中为共享)成员是线程安全的。不保证所有实例成员都对于线程安全的。

请参阅

参考

System.Data.SqlServerCe 命名空间