revOpenDatabase and revCloseDatabase

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
manicsurfer
Posts: 7
Joined: Mon Jul 21, 2008 6:36 am

revOpenDatabase and revCloseDatabase

Post by manicsurfer » Mon Jul 28, 2008 8:04 am

Hello

I am new to RR. Currently, I am just testing, creating sample scripts to get used to working in the RR environment. I require a little hint, with regards to revOpenDatabase and revCloseDatabase. Here's the story.

I connect to a MySQL database (a remote one) with this is;

on mouseUp
put revOpenDatabase("MySQL","myTestServer.com","myDatabaseName","myDatabaseUser","myDatabasePassword") into dataConnectionID
if dataConnectionID is a number then
put dataConnectionID into field "fdbID"
else
answer dataConnectionID
end if
end mouseUp


So far (I think?!) so good, the script connects and puts the dataConnectionID in to a field called fdbID.

Now, I try to close the connection with this script;

on mouseUp
revCloseDatabase dataConnectionID
answer "Connection Terminated!"
end mouseUp


When I use this script to disconnect I get this error;

Type revdberr,invalid connection id
Object MySQL Close
Line revCloseDatabase dataConnectionID
Hint revCloseDatabase

Can anyone explain what it is I am doing wrong with this as according to the documentation I need to use the revCloseDatabase command including the connection variable - dataConnectionID - which I have done.

Any hints gratefully accepted!

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Mon Jul 28, 2008 10:55 am

The error report says that you have an invalid database id. That makes me wonder whether you have not got a value in your dataConnectionID because it is a local variable to your disconnection handler. If you declare dataConnectionID as a global variable, (or as a script local variable where the two handlers are in the same script) then you should be able to reuse the variable in different handlers with the value being preserved between them. If you declare "global dataConnectionID" before the "on mouseUp" on each button script, (or in the disconnect script, set the value of the variable by reading from the field where you stored the connection id) do you get the same problem?

manicsurfer
Posts: 7
Joined: Mon Jul 21, 2008 6:36 am

Post by manicsurfer » Mon Jul 28, 2008 2:04 pm

Thanks Sparkout

I have altered then to

on mouseUp
global gDataConnectionID
put revOpenDatabase("MySQL","myTestServer.com","myDatabaseName","myDatabaseUser","myDatabasePassword") into dataConnectionID
if dataConnectionID is a number then
put dataConnectionID into field "fdbID"
put dataConnectionID into gDataConnectionID
else
answer dataConnectionID
end if
end mouseUp

SO, then I carry the gDataConnectionID to another button that terminates the connection using the global gDataConnection as the ID!

Thanks for that

I'm storming ahead now :) ...I have pretty much wrapped up MySQL connections, terminations and queries so thats cool. However, do you know of a way that results can be listed (like when using mysql and php) say 10 to a page and then we can page through the recordset using a next page, previous page etc...one of my tables has 3500 records...I would like to spread those results over a number of pages for speed?

pmchacin
Posts: 6
Joined: Wed Dec 17, 2008 5:14 am

can you help me please?

Post by pmchacin » Thu Dec 18, 2008 5:17 am

Hello, I have a problem using RR an mysql on Linux. I copy your code for connection and work fine on Windows plataform but on Linux not work.
Just do not say anything, no error, does not run the code after the attempt to connect. Can you help me?

Note: I using a traductor Spanish - English.

Post Reply