SqlCeErrorCollection.Item 屬性
取得在指定索引處的錯誤。
命名空間: System.Data.SqlServerCe
組件: System.Data.SqlServerCe (在 System.Data.SqlServerCe.dll 中)
語法
'宣告
Public ReadOnly Default Property Item ( _
index As Integer _
) As SqlCeError
Get
'用途
Dim instance As SqlCeErrorCollection
Dim index As Integer
Dim value As SqlCeError
value = instance(index)
public SqlCeError this[
int index
] { get; }
public:
property SqlCeError^ default[int index] {
SqlCeError^ get (int index);
}
member Item : SqlCeError
JScript 支援使用索引的屬性,但不支援新的宣告。
參數
- index
型別:System.Int32
要擷取之 SqlCeError 的以零為基底的索引。
屬性值
型別:System.Data.SqlServerCe.SqlCeError
SqlCeError ,包含指定索引處的錯誤。
範例
下列範例會顯示 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);
}
}