LastError Property (Read Only)

NI DataSocket

LastError Property (Read Only)

Syntax

CWDataSocket.LastError

Data Type

Long

Purpose

Specifies the last error code used in an OnStatusUpdated event.

Remarks

The value of LastError is 0 if no error occurred the last time OnStatusUpdated was generated.

Some common errors include errors caused by incorrect network configurations, insufficient access privileges to connect to the data source, or an incorrectly formed URL.

The value of the error code is an HRESULT, the ActiveX data type used for reporting errors. It might include errors detected by the CWDataSocket or by the operating systems networking services. If an error is encountered, the message that goes with the last error is stored in the LastMessage property.

To determine the task the CWDataSocket object was performing when the error occurred, check the LastMessage and Status properties.

Example

'Display the current status in the form
'[status:error] Message
Dim str As String

If (CWDataSocket1.StatusUpdated) Then
   str = "[" & CWDataSocket1.Status & ":" & _
           CWDataSocket1.LastError & "]" & _
           CWDataSocket1.LastMessage
   MsgBox str
End If

See Also

LastMessage

Status

OnStatusUpdated