I have a simple VBScript to test connection to Oracle Database:
Dim strSQL, strDataSource, strUsername, strPassword
Set dbData = CreateObject("ADODB.Recordset")
Set dbConnection = CreateObject("ADODB.Connection")
dbConnection.ConnectionString = "Provider=OraOLEDB.Oracle;Data Source="MyDB";User ID="MyUser";Password="MyPassword";"
dbConnection.Open
strSQL = "SELECT 1 FROM DUAL"
dbData.Open strSQL, dbConnection
If (dbData.EOF) Then
WScript.Echo "There are No records to retrieve"
Else
WScript.Echo "There are records to retrieve."
End If
dbData.Close
dbConnection.Close
The script is querying the DUAL table, and if 1 row is retrieved. that's an indicator that the database is online.
Problem is, that sometimes the user account that I'm using with, get locked on the database, and I'm getting the following error output from the script:
ORA-28000: the account is locked
Is there any way to capture this error in VBScript?
Because I want to add another Echo
in the script, in case the user is locked.