Opening SQLite
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
sandybassett
- Posts: 35
- Joined: Fri May 31, 2013 7:44 pm
Opening SQLite
I've finally got the correct syntax for opening a SQLite database, creating a table, entering data and displaying data. Works great, so easy after you know it. Now I want to start making it user-friendly for users. Now (as in the lessons) you click a button to open the database before proceeding. How can I make it so it opens automatically when the program starts? without user action. I tried on open, on preopen, etc and that always produces error messages at the databaseconnect line. Surely there is some way. Thanks for any help.
Re: Opening SQLite
Hi Sandy,
## I tried on open, on preopen...
open and preopen what?
Where is your databqse located?
Please post your script(s), guessing is ineffective
Best
Klaus
## I tried on open, on preopen...
open and preopen what?
Where is your databqse located?
Please post your script(s), guessing is ineffective
Best
Klaus
-
sandybassett
- Posts: 35
- Joined: Fri May 31, 2013 7:44 pm
Re: Opening SQLite
Here's my code:
global gDatabasePath,gDatabaseID
on databaseConnect ##put into preopen
put specialFolderPath("desktop") & "/apartments.sqlite" into gDatabasePath
put revOpenDatabase("sqlite", gDatabasePath, , , , ) into myDatabaseID
if myDatabaseID is an integer then
put myDatabaseID into gDatabaseID
answer "Good Connection"
else
beep
answer error "An error occurred:" && item 2 of myDatabaseID
end if
end databaseConnect
The "on databaseConnect" routine works fine from a user button mouse up call, but what I want is a way to make it operate automagically when the stack is turned on, with no operator action required. Thanks for your help.
global gDatabasePath,gDatabaseID
on databaseConnect ##put into preopen
put specialFolderPath("desktop") & "/apartments.sqlite" into gDatabasePath
put revOpenDatabase("sqlite", gDatabasePath, , , , ) into myDatabaseID
if myDatabaseID is an integer then
put myDatabaseID into gDatabaseID
answer "Good Connection"
else
beep
answer error "An error occurred:" && item 2 of myDatabaseID
end if
end databaseConnect
The "on databaseConnect" routine works fine from a user button mouse up call, but what I want is a way to make it operate automagically when the stack is turned on, with no operator action required. Thanks for your help.
Re: Opening SQLite
In the stack script :sandybassett wrote: The "on databaseConnect" routine works fine from a user button mouse up call, but what I want is a way to make it operate automagically when the stack is turned on, with no operator action required. Thanks for your help.
Code: Select all
on openstack
databaseConnect
end openstackThat will do. Watchout if you use datagrids and you edit template, or substack (because in this case, openstack will be fired again).
Re: Opening SQLite
Hi Sandy,
as bangkok says
Hint: There is no "open" or preopen" message!
You probably mean "preopenSTACK" or "preopenCARD" or "openCARD" or "preopencard", right?
Best
Klaus
as bangkok says
Hint: There is no "open" or preopen" message!
You probably mean "preopenSTACK" or "preopenCARD" or "openCARD" or "preopencard", right?
Best
Klaus
