Invalid connection ID
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 13
- Joined: Sat Apr 15, 2006 10:03 am
- Location: Italia
Invalid connection ID
Hi,
I am trying a query to MySQL database using MacOS X 10.4.6 and Rev 2.6.1.
When I am in IDE environment all works fine, but when I make a standalone application I have the following error:
-the connection is OK
the revOpenDatabase returns a connection ID
-the first query returns the error : revdberr, invalid connection ID
Have you any suggestion?
Thanks in advance
I am trying a query to MySQL database using MacOS X 10.4.6 and Rev 2.6.1.
When I am in IDE environment all works fine, but when I make a standalone application I have the following error:
-the connection is OK
the revOpenDatabase returns a connection ID
-the first query returns the error : revdberr, invalid connection ID
Have you any suggestion?
Thanks in advance
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
Re: Invalid connection ID
Hi Riccardo,
Could you post the exact script here?
It should be something like:
Also, if you're using the revdb_querylist function (or its synonym revDataFromQuery) then the connectionID is the third parameter, as the first and second parameter are the column and row delimiter, respectively.
Hope this helped,
Jan Schenkel.
Could you post the exact script here?
It should be something like:
Code: Select all
on mouseUp
put revdb_connect("mysql","host:port","schema","user,"password") into tConnectionID
if tConnectionID is not a number then
answer error tConnectionID
exit mouseUp
end if
put revdb_query(tConnectionID,"SELECT * FROM foobar") into tCursorID
if tCursorID is not a number then
answer error tCursorID
exit mouseUp
end if
-- do some more stuff with the db cursor
-- ...
-- cleanup time
get revdb_closecursor(tCursorID)
get revdb_disconnect(tConnectionID)
end mouseUp
Hope this helped,
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
-
- VIP Livecode Opensource Backer
- Posts: 1236
- Joined: Sat Apr 08, 2006 1:10 pm
- Location: Zurich
- Contact:
Have you checked if the inclusions are there? there needs to be an mysql file next to the executable in the bundle. Sometimes Rev doesn't add them automatically, and you have to do it by hand. THere are 2 ways to do that:
In the "General" tab of the "Standalone Application Settings..." you can choose "Select inclusions for standalone application".
Then check "Database support" and make sure the "mysql" line is selected in the field below that checkbox.
If that doesn't help, you need to copy the mysql external yourself from the rev standalone to your app bundle.
In the "General" tab of the "Standalone Application Settings..." you can choose "Select inclusions for standalone application".
Then check "Database support" and make sure the "mysql" line is selected in the field below that checkbox.
If that doesn't help, you need to copy the mysql external yourself from the rev standalone to your app bundle.
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
Hi Riccardo,
If it works inside the Rev IDE, but not in your standalone, that's quite puzzling. As I don't know how your app works, I can only suggest that you add the following line just before your call to revdb_query, so you can check if you're using the wrong connection ID, or if some other piece of code has closed the connection behind your back.
Hope this brings you closer to the solution,
Jan Schenkel.
If it works inside the Rev IDE, but not in your standalone, that's quite puzzling. As I don't know how your app works, I can only suggest that you add the following line just before your call to revdb_query, so you can check if you're using the wrong connection ID, or if some other piece of code has closed the connection behind your back.
Code: Select all
answer "revdb_connections:" && revdb_connections() & return & "tConnectionID:" && tConnectionID
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
-
- VIP Livecode Opensource Backer
- Posts: 13
- Joined: Sat Apr 15, 2006 10:03 am
- Location: Italia
I have checked the external files and they are OK.
As Jan suggested, I have verified the open connections before the query and I have discovered that I have no active connections.
It is very strange because the same app worked same days ago and in IDE environment it works again now.
I don't have any close database commands. Only in the shutdownrequest handler I close the database connection, but if I put an answer command, in order to debug the event handler, I can note that it is not called before.
Is there any condition for automatic database closing in standalone or have you any other suggestions?
Thank
riccardo
As Jan suggested, I have verified the open connections before the query and I have discovered that I have no active connections.
It is very strange because the same app worked same days ago and in IDE environment it works again now.
I don't have any close database commands. Only in the shutdownrequest handler I close the database connection, but if I put an answer command, in order to debug the event handler, I can note that it is not called before.
Is there any condition for automatic database closing in standalone or have you any other suggestions?
Thank
riccardo
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
In that case, put an answer command right after the database connection is opened, to make sure that this handler is called:
For debugging purposes, you could also trap the revdb_disconnect function yourself before it is passed on to the external library, so you can display a message, and pass it on or not. Add the following code to your mainStack script:
Of course, this won't trap a call to the 'revCloseDatabase' command, but I'll leave that bas an exercise to the reader
Let us know how it works out for you.
Jan Schenkel.
Code: Select all
put revdb_connect("mysql","host:port","schema","user,"password") into tConnectionID
answer "Opened connection:" && tConnectionID
Code: Select all
function revdb_disconnect pConnectionID
put "revdb_disconnect() called: & return & \
"--" && "the executionContexts" && "--" & return & \
the executionContexts & return & \
"--" && "connection ID" && "--" & return & \
pConnectionID & return & \
"--" && "revdb_connections()" && "--" & return & \
revdb_connections() \
into tPrompt
answer tPrompt with "OK" or "Cancel"
if it is "OK" then pass revdb_disconnect
end revdb_disconnect
Let us know how it works out for you.
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
-
- VIP Livecode Opensource Backer
- Posts: 13
- Joined: Sat Apr 15, 2006 10:03 am
- Location: Italia
Thanks Jan,
I found the error and I hope that it can help others.
The problem is in the following code located in the openstack handler of the main stack:
If I use the code in IDE environment it works, but if I build the standalone same library stacks are added to the substack list.
In particular when the above script sets the decoration of the revMaxCursor stack the connection is closed and obviously any subsequent query command returns an invalid connection ID.
This happens only if I use this type of decoration. If I set the decorations to default it works.
In order to avoid this problem I use these modified script:
riccardo
I found the error and I hope that it can help others.
The problem is in the following code located in the openstack handler of the main stack:
Code: Select all
put the substacks of stack "Xdent" into lista
repeat with i=1 to the num of lines of lista
put line i of lista into finestra
set the decorations of stack finestra to "title,menu,minimize,maximize,close,metal"
end repeat
In particular when the above script sets the decoration of the revMaxCursor stack the connection is closed and obviously any subsequent query command returns an invalid connection ID.
This happens only if I use this type of decoration. If I set the decorations to default it works.
In order to avoid this problem I use these modified script:
Code: Select all
put the substacks of stack "Xdent" into lista
repeat with i=1 to the num of lines of lista
put line i of lista into finestra
if char 1 to 3 of finestra<>"rev" and word 2 of finestra<>"dialog" then
set the decorations of stack finestra to "title,menu,minimize,maximize,close,metal"
end if
end repeat
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
Thanks for the update - have you submitted this problem to bugzilla?
That way the RunRev engineers can study it and provide a fix.
Jan Schenkel.
That way the RunRev engineers can study it and provide a fix.
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com