Livecode Database functions fail

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
gdmipad
Posts: 5
Joined: Thu Jun 20, 2013 1:41 pm

Livecode Database functions fail

Post by gdmipad » Thu Jun 20, 2013 1:47 pm

I've been playing around with the livecode database functions with success for some time.
Since a few weeks none of the database functions work anymore.
Not in livecode 4.6.2 and not in livecode community 6.0.2.
The error I get is :

(Function: error in function handler) near "revOpenDatabase", char 12

Has anyone encountered the same problem ? What am I doing wrong here ?

Klaus
Posts: 14206
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Livecode Database functions fail

Post by Klaus » Thu Jun 20, 2013 1:53 pm

Hi gdmipad,

please post the (relevant parts of) the script.


Best

Klaus

gdmipad
Posts: 5
Joined: Thu Jun 20, 2013 1:41 pm

Re: Livecode Database functions fail

Post by gdmipad » Thu Jun 20, 2013 2:17 pm

Hi Klaus,

I get this error in every stack where database functions are used.
Also in the example stacks provided by Livecode, i.e. :

on mouseUp

local tDatabasePath, tSQLQuery

## Connect to the database
## Save the connection id
put specialFolderPath("desktop") & "/Beginners Course/Lesson 5/Sample Stacks/emailaddresses.sqlite" into tDatabasePath
put revOpenDatabase("sqlite",tDatabasePath,,,,) into sDatabaseID

## Check that the connection was successful
if sDatabaseID is not a number then
answer "Could not connect to database"
end if

end mouseUp

OR when trying to connect to a mysql database :
    
    put revOpenDatabase("mysql", tDatabaseAddress, tDatabaseName, tDatabaseUser, tDatabasePassword) into tResult
(--> can't post the domain references here because my account doesn't permit)

I always get the same error on the revOpenDatabase function.
As if it can't find the library or something ? It seems like livecode doesn't recognize the function...

Klaus
Posts: 14206
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Livecode Database functions fail

Post by Klaus » Thu Jun 20, 2013 2:42 pm

Hi gdmipad,

Ok, here we go... :-)

1. Put the variable declaration at the top of the script and not within the mouseup-handler:
#########################
local tDatabasePath, tSQLQuery

on mouseup
...
########################

2. You are using two different variable names:
...
put revOpenDatabase("sqlite",tDatabasePath,,,,) into sDatabaseID
...
sDatabaseID <> tDatabaseID


Best

Klaus

gdmipad
Posts: 5
Joined: Thu Jun 20, 2013 1:41 pm

Re: Livecode Database functions fail

Post by gdmipad » Thu Jun 20, 2013 2:59 pm

Hi Klaus,

I placed the declarations outside the mouseup handler but with no success.
I only used sDatabaseID as far as I can see, besides I copied the code straight from the livecode samples code.

I don't think the problem lies in the code because I've tested several Livecode samples connecting to different
databases (sqlite, mysql).

Livecode doesn't recognize the function revOpenDatabase for some reason :-(

Klaus
Posts: 14206
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Livecode Database functions fail

Post by Klaus » Thu Jun 20, 2013 3:30 pm

Oops, sorry, my fault, I mixed sDatabasePath with sDatabaseID.

Hm, is sDataBaseID declared somehwere as local of global?
And is this a standalone? Mac or Win?

You could check if the database driver got copied to the "externals" folder when building a standalone.

gdmipad
Posts: 5
Joined: Thu Jun 20, 2013 1:41 pm

Re: Livecode Database functions fail

Post by gdmipad » Thu Jun 20, 2013 4:21 pm

Hi Klaus,

I finally resolved my problem by completely erasing Livecode and reinstalling it.
Then in preferences - Compatibility I had to download new drivers and use the legacy drivers.
After closing down Livecode and restarting Livecode it finally worked.

Thanx for your feedback on this matter !

Klaus
Posts: 14206
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Livecode Database functions fail

Post by Klaus » Thu Jun 20, 2013 5:01 pm

Hi gdmipad,

glad you could solve it! But that's too funky, innit? :-)


Best

Klaus

gdmipad
Posts: 5
Joined: Thu Jun 20, 2013 1:41 pm

Re: Livecode Database functions fail

Post by gdmipad » Thu Jun 20, 2013 7:05 pm

I certainly lost some hairs during the process ;-)

Post Reply