Sqlite problems

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
chris9610
Posts: 79
Joined: Fri Mar 20, 2009 4:38 pm

Sqlite problems

Post by chris9610 » Tue Dec 08, 2009 9:45 pm

I have a very small application which saves the data to a sqlite database and works great until I compile it.

The following stack script code works great in the IDE but not compiled in 4.0.

Code: Select all

global gconId
on preopenstack
   opendb
end preopenstack
on opendb
    put revOpenDatabase("sqlite", "C:/Estimate Data/Estimate Info.dat", , , , ) into tConId
   if tConID is "" then 
      answer warning "Problem creating or accessing database!"
   else
      answer information "AppReg Connected! Your connection ID is: " & tConID
      put tConID into gConID
       end if
end opendb
Does anyone have a clue as to why? I have included the database externals but no worky.
Do I need to move the external dlls to the windows folder to work after compiled?
Developing with Windows XP & Revolution 4.5

David_USA
Posts: 8
Joined: Sun Jun 29, 2008 6:30 pm
Contact:

Re: Sqlite problems

Post by David_USA » Wed Dec 09, 2009 6:57 am

Have you tried saving it by declaring your global with the same exact format?

you have the global declared as
global gconId
and then modify it
put tConID into gConID
Have you tired declaring
global gConID
?

Code: Select all

global gconId
on preopenstack
   opendb
end preopenstack
on opendb
    put revOpenDatabase("sqlite", "C:/Estimate Data/Estimate Info.dat", , , , ) into tConId
   if tConID is "" then
      answer warning "Problem creating or accessing database!"
   else
answer information "AppReg Connected! Your connection ID is: " & tConID
put tConID into gConID
end if
end opendb

chris9610
Posts: 79
Joined: Fri Mar 20, 2009 4:38 pm

Re: Sqlite problems

Post by chris9610 » Wed Dec 09, 2009 8:10 pm

Sorry David

The script never gets to that point.

I do not get connected or the not connected answer. In fact it is like the script is ignored entirely in the compiled code.
Developing with Windows XP & Revolution 4.5

chris9610
Posts: 79
Joined: Fri Mar 20, 2009 4:38 pm

Re: Sqlite problems

Post by chris9610 » Wed Dec 09, 2009 8:15 pm

I just tried the suggestions wit the same results. The script works perfectly in the IDE and does not execute in the compiled mode.
Developing with Windows XP & Revolution 4.5

chris9610
Posts: 79
Joined: Fri Mar 20, 2009 4:38 pm

Re: Sqlite problems

Post by chris9610 » Wed Dec 09, 2009 8:24 pm

I just tried again and I inserted an answer line right after the line

Code: Select all

    put revOpenDatabase("sqlite", "C:/Estimate Data/Estimate Info.dat", , , , ) into tConID
The answer line does not execute. This means the failure is in the open database line in the compiled code.
Developing with Windows XP & Revolution 4.5

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Sqlite problems

Post by sturgis » Wed Dec 09, 2009 8:35 pm

Out of curiosity, would you mind shifting your code from preopenstack to openstack and try again?

Edit: also, if you put a simple answer "this is a test" into the preopenstack handler does it execute from there?
chris9610 wrote:I just tried again and I inserted an answer line right after the line

Code: Select all

    put revOpenDatabase("sqlite", "C:/Estimate Data/Estimate Info.dat", , , , ) into tConID
The answer line does not execute. This means the failure is in the open database line in the compiled code.

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: Sqlite problems

Post by malte » Wed Dec 09, 2009 8:42 pm

Did you include the error dialog into your standalone? (Standalone application settings-> Bug reports)

If so, does it throw anything? If not, could you?

Cheers,

Malte

chris9610
Posts: 79
Joined: Fri Mar 20, 2009 4:38 pm

Re: Sqlite problems

Post by chris9610 » Wed Dec 09, 2009 8:53 pm

The error Dialog is in the compiled code. I also tried a button to execute the on opendb.

The opendb script still fails.
Developing with Windows XP & Revolution 4.5

chris9610
Posts: 79
Joined: Fri Mar 20, 2009 4:38 pm

Re: Sqlite problems

Post by chris9610 » Wed Dec 09, 2009 8:55 pm

Sorry I did not understand about the error Dialog included, but I will try it.
Developing with Windows XP & Revolution 4.5

chris9610
Posts: 79
Joined: Fri Mar 20, 2009 4:38 pm

Re: Sqlite problems

Post by chris9610 » Wed Dec 09, 2009 9:04 pm

Well I tried the error Dialog Bug Reports and then recompiled to no avail.

Nothing happens when I try to connect to the sqlite database. No Errors. It is like the code is totally ignored.
Developing with Windows XP & Revolution 4.5

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: Sqlite problems

Post by malte » Wed Dec 09, 2009 10:55 pm

Hey Chris,

just reproduced it. It appears, that the database Libraries are not yet fully loaded on preOpenstack of the mainstack that turns into the application. In the IDE these libs will be loaded already. If you move your script to openStack as sturgis already suggested.

Cheers,

malte

chris9610
Posts: 79
Joined: Fri Mar 20, 2009 4:38 pm

Re: Sqlite problems

Post by chris9610 » Thu Dec 10, 2009 4:08 am

Ok I moved the script to openstack and it still does not work.

Also I tried calling the opendb from a script in a button after everything is loaded and it still does not work.

While making the standalone the database externals are loaded so I have no idea as to why the script refuses to execute and it works so good in the IDE.
Developing with Windows XP & Revolution 4.5

chris9610
Posts: 79
Joined: Fri Mar 20, 2009 4:38 pm

Re: Sqlite problems

Post by chris9610 » Thu Dec 10, 2009 4:21 am

OK I finally got it working. I had "on preopenstack" in the stack script and the card script.

Once they were eliminated then the openstack script called the opendb and all is well.

It seems as though if the database connect script is in any "on preopenstack" the script gets set aside and produces no execution or errors. This seems like a bug.

Thank you for your help.
Developing with Windows XP & Revolution 4.5

oliverk
Site Admin
Site Admin
Posts: 53
Joined: Mon Feb 27, 2006 2:16 pm
Location: Edinburgh

Re: Sqlite problems

Post by oliverk » Fri Dec 11, 2009 5:46 pm

Hi,

Unfortunately I didn't spot this message until after the solution was found.

For what its worth, the reason for this problem is how Externals (like revDB) are loaded in Revolution standalone applications. Revolution places a hidden group in your stack, which initializes the externals when it receives its first preOpenBackground message. Once this has happened, everything works fine, but if you try to connect before this, (e.g. on preOpenStack) then it will fail.

I've posted a comment to the revOpenDatabase function to explain this and hopefully help prevent people having this problem in the future.

Regards
Oliver
Oliver Kenyon
Software Developer
Runtime Revolution

chris9610
Posts: 79
Joined: Fri Mar 20, 2009 4:38 pm

Re: Sqlite problems

Post by chris9610 » Thu Dec 17, 2009 1:57 pm

oliverk:

Thank you for the good information. It is very important to know how externals are put to use.

Happy Holidays!
Developing with Windows XP & Revolution 4.5

Post Reply

Return to “Databases”