SqlCeErrorCollection.Item Property
Gets the error at the specified index.
Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in system.data.sqlserverce.dll)
Syntax
'Declaration
Public ReadOnly Default Property Item ( _
index As Integer _
) As SqlCeError
'Usage
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] {
SqlCeError^ get (int index);
/** @property */
public SqlCeError get_Item (int index)
JScript supports the use of indexed properties, but not the declaration of new ones.
Parameters
- index
The zero-based index of the SqlCeError to retrieve.
Property Value
A SqlCeError that contains the error at the specified index.
Example
The following example displays each SqlCeError within the SqlCeErrorCollection collection.
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);
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .
Platforms
Windows CE, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows XP Professional x64 Edition, Windows XP SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Version Information
.NET Compact Framework
Supported in: 2.0, 1.0
See Also
Reference
SqlCeErrorCollection Class
SqlCeErrorCollection Members
System.Data.SqlServerCe Namespace