Main Form Event handler Open database

Hello,
I just created a new project and thought it would make sense to open the database using an “Open” Event Handler. Seems to work okay until I created a button on the form to get the Table Schema. Xojo keeps telling me there is no database opened by the name given to the TableSchema command.

Is there some caution about events not being global?

I moved the TableSchema under the open event and it worked fine there.

Thanks,
Jeff

OPENING the database that way is fine…
the question is where did you DIM the database???
If that is also in the open event… the it goes out of scope the instant that event completes.

DIM it in a module if you want to do it that way

Thanks Dave. That must be it.

You were right about how I had the DIM setup. I now have setup a Property on the app of DB as OracleDatabase with a Scope of Public. That part seems to work there because I haven’t had to declare it anywhere else.
I created a button with an Activate action that contains the Oracle connection information and it works if I click the button.
But how can I have the Oracle connection take place when the app launches? I tried creating an Open Event Handler to do this but now it complains that the DB item doesn’t exist.

I apologize for being new at this.

post some code

if you DIM the connection variable in a global location
and then Initate it in the APP.open that should work just fine

it is all about SCOPE… where things are done, what order they are done int, and what their lifetime is

This is App/Event Handler/Open:

CLIPS = New OracleDatabase
CLIPS.DatabaseName = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=someserver)(PORT=1521))(CONNECT_DATA=(SERVER = DEDICATED)(SERVICE_NAME = service)))"
CLIPS.UserName = "username"
CLIPS.Password = "password"
CLIPS.Debug = 1

If CLIPS.Connect Then
  MsgBox("Connected to Oracle!")
Else
  MsgBox("Error connecting to Oracle: " + CLIPS.ErrorMessage)
End If

And then I have App/Properties/CLIPS setup as:
Name: CLIPS
Type: OracleDatabase
Scope:Public

With it setup this way I get
“This item does not exist
if CLIPS.Connect then”

I don’t think I get where to put a DIM that is a Global area, at least not in Xojo.

create a MODULE and put it there

I got it, the module kept throwing me off.
Thank you!

[quote=343352:@Jeff Ridder]With it setup this way I get
“This item does not exist
if CLIPS.Connect then”[/quote]
If you put a property in app, you must namespace it:

if app.CLIPS.Connect then