SqlCeError Class
Collects information relevant to a warning or error returned by the data source. This class cannot be inherited.
Inheritance Hierarchy
System.Object
System.Data.SqlServerCe.SqlCeError
Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)
Syntax
'Declaration
<SerializableAttribute> _
Public NotInheritable Class SqlCeError
'Usage
Dim instance As SqlCeError
[SerializableAttribute]
public sealed class SqlCeError
[SerializableAttribute]
public ref class SqlCeError sealed
[<SealedAttribute>]
[<SerializableAttribute>]
type SqlCeError = class end
public final class SqlCeError
The SqlCeError type exposes the following members.
Properties
Name | Description | |
---|---|---|
ErrorParameters | Gets the last three error parameters. Error parameters are used by SQL Server Compact to provide additional details about an error. | |
HResult | Returns an HRESULT value that identifies the type of error. | |
Message | Gets the text describing the error. | |
NativeError | Gets the native error number of the SqlCeError. For more information about these errors, see "SQL Server Compact Errors" in the Troubleshooting section of SQL Server Compact Books Online. | |
NumericErrorParameters | Gets the first three error parameters. Error parameters are used by SQL Server Compact to provide additional details about an error. | |
Source | Gets the name of the provider that generated the error. |
Top
Methods
Name | Description | |
---|---|---|
Equals | (inherited from Object) | |
Finalize | (inherited from Object) | |
GetHashCode | (inherited from Object) | |
GetType | (inherited from Object) | |
MemberwiseClone | (inherited from Object) | |
ToString | Gets the complete text of the error message. (Overrides Object.ToString().) |
Top
Remarks
An instance of SqlCeError is created by the System.Data.SqlServerCe managed provider when an error occurs. The SqlCeErrorCollection contains one or more instances of SqlCeError.
Examples
The following example shows a typical use of 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);
}
}
Thread Safety
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.