mainDB is an Object
If you have not created an instance using NEW then it is Nil
I would suggest reading the various user guides & possibly the tutorials specifically chapter 4 of the User Guide - frameworks book available for free from http://www.xojo.com/download/extras.php
If your application never creates one the exception will always be raised
I would not use a catchall exception like that
Maybe something like
[code]try
If maindb.Connect then
CreateStatusLabel.text = (“Banco de Dados PRINCIPAL conectado.”)
else
CreateStatusLabel.text = (“Banco de Dados PRINCIPAL NO conectado. Crie ou conecte.”)
end if
catch err as NilObjectException
CreateStatusLabel.text = (“Banco de Dados PRINCIPAL NO conectado. Crie ou conecte.”)
end try
[/code]
I did this … not sure if the pragma is the right place… but it is working now in the debugg.
#pragma BreakOnExceptions Off
Try
If maindb.Connect then
CreateStatusLabel.text = ("Banco de Dados PRINCIPAL conectado.")
else
CreateStatusLabel.text = ("Banco de Dados PRINCIPAL NO conectado. Crie ou conecte.")
end if
Catch err as NilObjectException
CreateStatusLabel.text = ("Banco de Dados PRINCIPAL NO conectado. Crie ou conecte.")
In debug mode the application will stop on the exception BUT you can just hit resume
I find it a useful way to make sure that my application ha handled the exceptions that I know are going to be raised