UltraLite ActiveX User's Guide
Understanding UltraLite ActiveX Development
Error handling
You can use the standard eMbedded Visual Basic error-handling features to handle errors. To enable error handling, use the On Error Resume Next statement. On Error Goto 0 causes errors to halt execution of your code.
The Err.Number property holds the SQLCODE value for an error. You can also get the last error using the ULConnection.LastErrorCode property.
One common area where errors need to be caught is in handling missing database files. In the following example, On Error Resume Next is in effect, so control flows to the next statement following the one causing the error. If the specified database does not exist, the Err object is loaded with the error number and description.
' eMbedded Visual Basic On Error Resume Next Err.Clear ' Clear any previous errors Set Connection = DBMgr.OpenConnection(udb) If Err.Number <> 0 Then ' Connection failed, no database? Err.Clear Set Connection = DBMgr.CreateDatabase(udb & usm) If Err.Number <> 0 Then MsgBox "Connect with " & udb & usm & " failed: " & Err.Description App.End End If End If