基础提供程序从 SQL Server Compact 3.5 数据源返回警告或错误时引发的异常。 无法继承此类。
命名空间: System.Data.SqlServerCe
程序集: System.Data.SqlServerCe(在 System.Data.SqlServerCe.dll 中)
语法
声明
<SerializableAttribute> _
Public Class SqlCeException _
Inherits SystemException
用法
Dim instance As SqlCeException
[SerializableAttribute]
public class SqlCeException : SystemException
[SerializableAttribute]
public ref class SqlCeException : public SystemException
[<SerializableAttribute>]
type SqlCeException =
class
inherit SystemException
end
public class SqlCeException extends SystemException
注释
每当用于 SQL Server Compact 3.5 的 .NET Compact Framework 数据提供程序遇到 SQL Server Compact 3.5 引擎中生成的错误时,都将创建此类。 (其他错误作为标准的公共语言运行时异常引发。)SqlCeException 总是至少包含一个 SqlCeError 实例。
示例
下面的示例由于缺少数据源而生成一个 SqlCeException,然后显示该异常。
Dim conn As New SqlCeConnection("Data Source=nonExistingSource.sdf;")
Try
conn.Open()
Catch e As SqlCeException
' Use SqlCeException properties if you need specific
' application logic depending on the error condition
'
If 25046 = e.NativeError Then 'SSCE_M_FILENOTFOUND
' Error specific logic goes here...
'
End If
MessageBox.Show(e.Message)
End Try
SqlCeConnection conn = new SqlCeConnection("Data Source=nonExistingSource.sdf;");
try
{
conn.Open();
}
catch (SqlCeException e)
{
// Use SqlCeException properties if you need specific
// application logic depending on the error condition
//
if (25046 == e.NativeError /*SSCE_M_FILENOTFOUND*/)
{
// Error specific logic goes here...
//
}
MessageBox.Show(e.Message);
}
继承层次结构
System. . :: . .Object
System. . :: . .Exception
System. . :: . .SystemException
System.Data.SqlServerCe..::..SqlCeException
System.Data.SqlServerCe. . :: . .SqlCeInvalidDatabaseFormatException
System.Data.SqlServerCe. . :: . .SqlCeLockTimeoutException
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.