LastServerErrText Property

Description

Returns the textual message associated with the current LastServerErr property of the specified object. Not available at design time and read-only at run time.

Usage

error_text = orasession.LastServerErrText
error_text = oradatabase.LastServerErrText

Data Type

String

Remarks

The returned value indicates one of three possible states:

  1. If Null is returned, an Oracle Call Interface (OCI) database function has not returned an error since the most recent LastServerErrReset property.

  2. If a non-Null value is returned, an OCI function has returned an error code; the returned string is the associated message.

  3. If the message is empty, then no additional information was available.

Examples

This example demonstrates the use of the CreateDynaset method and the LastServerErr and LastServerErrText properties to determine whether an Oracle error has occurred and to display the error message. Copy and paste this code into the definition section of a form. Then, press F5.

Sub Form_Load ()
 
 'Declare variables as OLE Objects.
 Dim OraSession As OraSession 
 Dim OraDatabase As OraDatabase 
 Dim OraDynaset As OraDynaset 
 
 'Create the OraSession Object.
 Set OraSession = CreateObject("OracleInProcServer.XOraSession")
 
 'Set up an error handler.
 On Error GoTo errhandler 
 
 'Create the OraDatabase Object by opening a connection to Oracle.
 Set OraDatabase = OraSession.OpenDatabase("ExampleDb", "scott/tiger", 0&)
 
 'Attempt to Create the OraDynaset Object.
 'Notice that the FROM keyword is missing from the SQL statement.
 Set OraDynaset = OraDatabase.CreateDynaset("select * emp", 0&)
 
Exit Sub
 
errhandler:
 
 'Check to see if an Oracle error has occurred.
 If OraDatabase.LastServerErr <> 0 Then
  MsgBox OraDatabase.LastServerErrText
 Else 'Must be some non-Oracle error.
  MsgBox "VB:" & Err & " " & Error(Err)
 End If
 
 Exit Sub
 
End Sub