SqlCeException.Errors 属性
获取包含一个或多个 SqlCeError 对象的集合,这些对象包含有关 SQL Server Compact Edition .NET Compact Framework 数据提供程序产生的异常的详细信息。
命名空间: System.Data.SqlServerCe
程序集: System.Data.SqlServerCe(在 system.data.sqlserverce.dll 中)
语法
声明
Public ReadOnly Property Errors As SqlCeErrorCollection
用法
Dim instance As SqlCeException
Dim value As SqlCeErrorCollection
value = instance.Errors
public SqlCeErrorCollection Errors { get; }
public:
property SqlCeErrorCollection^ Errors {
SqlCeErrorCollection^ get ();
}
/** @property */
public SqlCeErrorCollection get_Errors ()
public function get Errors () : SqlCeErrorCollection
不适用。
属性值
包含为异常收集的 SqlCeError 类实例的 SqlCeErrorCollection 对象。
备注
SqlCeErrorCollection 类始终包含至少一个 SqlCeError 类的实例。
示例
下面的示例显示 SqlCeErrorCollection 集合中的每个 SqlCeError。
Try
Dim repl As New SqlCeReplication()
' Fill repl properites here
' ...
' SqlCeReplication may throw SqlCeException which contains a
' collection of errors; SQL Mobile database engine always
' returns one error in the collection
'
repl.Synchronize()
Catch e As SqlCeException
Dim err As SqlCeError
For Each err In e.Errors
' Use SqlCeError properties if you need specific
' application logic depending on the error condition
'
If 28577 = [err].NativeError Then 'SSCE_M_SCHEMAHASCHANGED
' Error specific logic goes here...
'
End If
' Note: For native error numbers, refer to SQL Server Mobile Errors
' in the SQL Server Mobile Books Online
'
MessageBox.Show([err].Message)
Next err
End Try
try
{
SqlCeReplication repl = new SqlCeReplication();
// Fill repl properites here
// ...
// SqlCeReplication may throw SqlCeException which contains a
// collection of errors; SQL Mobile database engine always
// returns one error in the collection
//
repl.Synchronize();
}
catch (SqlCeException e)
{
foreach (SqlCeError error in e.Errors)
{
// Use SqlCeError properties if you need specific
// application logic depending on the error condition
//
if (28577 == error.NativeError /*SSCE_M_SCHEMAHASCHANGED*/)
{
// Error specific logic goes here...
//
}
// Note: For native error numbers, refer to SQL Server Mobile Errors
// in the SQL Server Mobile Books Online
//
MessageBox.Show(error.Message);
}
}
平台
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、1.0
请参见
参考
SqlCeException 类
SqlCeException 成员
System.Data.SqlServerCe 命名空间