SqlCeException.NativeError 屬性
取得 SqlCeErrorCollection 中第一個 SqlCeError 的原生錯誤號碼。如需有關此錯誤的詳細資訊,請參閱《SQL Server Compact 線上叢書》中<疑難排解>一節內的「SQL Server Compact 錯誤」主題。
命名空間: System.Data.SqlServerCe
組件: System.Data.SqlServerCe (在 System.Data.SqlServerCe.dll 中)
語法
'宣告
Public ReadOnly Property NativeError As Integer
Get
'用途
Dim instance As SqlCeException
Dim value As Integer
value = instance.NativeError
public int NativeError { get; }
public:
property int NativeError {
int get ();
}
member NativeError : int
function get NativeError () : int
屬性值
型別:System.Int32
傳回 Int32。
範例
下列範例顯示 SqlCeErrorCollection 集合內第一個 SqlCeError 的 Message 和 NativeError 屬性。
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);
}
}