SqlCeErrorCollection Class
收集由 .NET Compact Framework Data Provider for SQL Server Compact 3.5 所產生的所有錯誤。這個類別無法被繼承。
命名空間: System.Data.SqlServerCe
組件: System.Data.SqlServerCe (在 system.data.sqlserverce.dll)
語法
'宣告
<DefaultMemberAttribute("Item")> _
Public NotInheritable Class SqlCeErrorCollection
Implements ICollection, IEnumerable
[DefaultMemberAttribute("Item")]
public sealed class SqlCeErrorCollection : ICollection, IEnumerable
[DefaultMemberAttribute(L"Item")]
public ref class SqlCeErrorCollection sealed : ICollection, IEnumerable
/** @attribute DefaultMemberAttribute("Item") */
public final class SqlCeErrorCollection implements ICollection, IEnumerable
DefaultMemberAttribute("Item")
public final class SqlCeErrorCollection implements ICollection, IEnumerable
備註
這個類別是由 SqlCeException 建立,可收集 SqlCeError 類別的執行個體。SqlCeErrorCollection 一定會至少包含一個 SqlCeError 類別的執行個體。
繼承階層
System.Object
System.Data.SqlServerCe.SqlCeErrorCollection
範例
下列範例會顯示 SqlCeErrorCollection 集合內的每個 SqlCeError。
Public Sub DisplaySqlCeErrors(ByVal errorCollection As SqlCeErrorCollection)
Dim err As SqlCeError
Dim bld As New StringBuilder()
For Each err In errorCollection
bld.Append((ControlChars.Cr & " Error Code: " & err.HResult.ToString("X")))
bld.Append((ControlChars.Cr & " Message : " & err.Message))
bld.Append((ControlChars.Cr & " Minor Err.: " & err.NativeError))
bld.Append((ControlChars.Cr & " Source : " & err.Source))
Dim numPar As Integer
For Each numPar In err.NumericErrorParameters
If 0 <> numPar Then
bld.Append((ControlChars.Cr & " Num. Par. : " & numPar))
End If
Next numPar
Dim errPar As String
For Each errPar In err.ErrorParameters
If [String].Empty <> errPar Then
bld.Append((ControlChars.Cr & " Err. Par. : " & errPar))
End If
Next errPar
MessageBox.Show(bld.ToString())
bld.Remove(0, bld.Length)
Next err
End Sub 'DisplaySqlCeErrors
public void DisplaySqlCeErrors(SqlCeErrorCollection errorCollection ) {
StringBuilder bld = new StringBuilder();
foreach (SqlCeError err in errorCollection) {
bld.Append("\n Error Code: " + err.HResult.ToString("X"));
bld.Append("\n Message : " + err.Message);
bld.Append("\n Minor Err.: " + err.NativeError);
bld.Append("\n Source : " + err.Source);
foreach (int numPar in err.NumericErrorParameters) {
if (0 != numPar) bld.Append("\n Num. Par. : " + numPar);
}
foreach (string errPar in err.ErrorParameters) {
if (String.Empty != errPar) bld.Append("\n Err. Par. : " + errPar);
}
MessageBox.Show(bld.ToString());
bld.Remove(0, bld.Length);
}
}
執行緒安全性
任何公用靜態 (共用 在 Microsoft Visual Basic) 此型別的成員具備執行緒安全。不保證任何執行個體成員安全執行緒。
平台
開發平台
Windows Vista, Windows Mobile 5.0, Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Mobile 2003 for Pocket PC, Windows CE 5.0
版本資訊
.NET Framework 及 NET Compact Framework
支援於 3.5
.NET Framework
支援於 3.0
.NET Compact Framework 及 .Net Framework
支援於 2.0
另請參閱
參考
SqlCeErrorCollection Members
System.Data.SqlServerCe Namespace
SqlCeError Class
SqlCeException