收集与数据源返回的警告或错误有关的信息。 无法继承此类。
命名空间: System.Data.SqlServerCe
程序集: System.Data.SqlServerCe(在 System.Data.SqlServerCe.dll 中)
语法
声明
Public NotInheritable Class SqlCeError
用法
Dim instance As SqlCeError
public sealed class SqlCeError
public ref class SqlCeError sealed
[<SealedAttribute>]
type SqlCeError = class end
public final class SqlCeError
注释
在发生错误时,System.Data.SqlServerCe 托管提供程序将创建一个 SqlCeError 的实例。 SqlCeErrorCollection 包含 SqlCeError 的一个或多个实例。
示例
下面的示例演示 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);
}
}
继承层次结构
System. . :: . .Object
System.Data.SqlServerCe..::..SqlCeError
线程安全
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.