Using Databases with Query Builder in standalone app
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 36
- Joined: Fri Jan 01, 2010 12:11 am
Using Databases with Query Builder in standalone app
My revolution 4.0 stack works quite well on Wndows XP using a SQLite database on a server. When I create a standalone app, the three queries defined in the query builder do not seem to work. I use the option to automatically include the required elements and the sqlite driver appears in the externals folder. I should have more information as I add more error checking...
-
- Posts: 36
- Joined: Fri Jan 01, 2010 12:11 am
Re: Using Databases with Query Builder in standalone app
I can get almost the same results in the revolution stack if I start it without being connected to the network. This prevents the database queries stored by the Database Query Builder from connecting to the database when stack starts. At that point, the revolution stack does not do queries just like the standalone app does not do queries. If I then connect to the network, and open the Query Builder, I can click the connect button on one of the queries and all three of my stored queries will then be connected (they connect to the same database). At this point the revolution stack works again.
So, is there a way to detect if a query built from the Query Builder is connected or not? And can I request it to be reconnected from code just like the "Connect" button in the Query Builder?
This might give me a workaround. When the stack runs as a stack, I get "answer error" dialogs when the queries built by the Query Builder do not connect to the database over the network. However, this does not occur when I run the standalone app.
So, is there a way to detect if a query built from the Query Builder is connected or not? And can I request it to be reconnected from code just like the "Connect" button in the Query Builder?
This might give me a workaround. When the stack runs as a stack, I get "answer error" dialogs when the queries built by the Query Builder do not connect to the database over the network. However, this does not occur when I run the standalone app.
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
Re: Using Databases with Query Builder in standalone app
You can use the revConnectionOfQuery function to see if there is a valid connection ID for a specific query, and use the revConnectQuery command to try and connect manually.
HTH,
Jan Schenkel.
Code: Select all
put "MyQueryName" into tQuery
if revConnectionOfQuery(tQuery) is empty then revConnectQuery tQuery
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
-
- Posts: 36
- Joined: Fri Jan 01, 2010 12:11 am
Re: Using Databases with Query Builder in standalone app
Thanks a 10^6 Jan. That did help and now I have it working. I added a handler that will test the connection to the database and then reconnect if any of the queries are not connected. I have a feeling that since all three queries are using the same database, that once I get one connected, they will all be connected. It seems that in the standalone application, the queries are not connected in the open stack handler, but when I run the .rev file, they are. So the fix is to simply display some text in a label and enable the "reconnect" button if the queries are not connected. That happens in the open stack handler. If the queries are not connected and the button is enabled, then the user clicks on the button to reconnect the queries.
If someone could check to see if the queries from the database query builder are connected at different times when my stack runs as a standalone app, that might clear up the last mystery of this post.
If someone could check to see if the queries from the database query builder are connected at different times when my stack runs as a standalone app, that might clear up the last mystery of this post.
-
- Posts: 36
- Joined: Fri Jan 01, 2010 12:11 am
Re: Using Databases with Query Builder in standalone app
One more question. Is there a "revDatabaseofQuery() function I can use to get the database name of a query? And then is there a function I can use to change the database of the query in case I want to switch from the production database to the test one and back?
-
- Posts: 36
- Joined: Fri Jan 01, 2010 12:11 am
Re: Using Databases with Query Builder in standalone app
After some more looking around, I found Jan's post on how to see the front script of the Database Query Manager (button in the toolbar of the message window). There seems to be a revChangeConnection handler that might allow me to change databases. Is that right? Maybe we could see more of these handlers in section 8.7.1 of the User's Guide?