Page 1 of 1

Sqlite problems

Posted: Tue Dec 08, 2009 9:45 pm
by chris9610
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?

Re: Sqlite problems

Posted: Wed Dec 09, 2009 6:57 am
by David_USA
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

Re: Sqlite problems

Posted: Wed Dec 09, 2009 8:10 pm
by chris9610
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.

Re: Sqlite problems

Posted: Wed Dec 09, 2009 8:15 pm
by chris9610
I just tried the suggestions wit the same results. The script works perfectly in the IDE and does not execute in the compiled mode.

Re: Sqlite problems

Posted: Wed Dec 09, 2009 8:24 pm
by chris9610
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.

Re: Sqlite problems

Posted: Wed Dec 09, 2009 8:35 pm
by sturgis
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.

Re: Sqlite problems

Posted: Wed Dec 09, 2009 8:42 pm
by malte
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

Re: Sqlite problems

Posted: Wed Dec 09, 2009 8:53 pm
by chris9610
The error Dialog is in the compiled code. I also tried a button to execute the on opendb.

The opendb script still fails.

Re: Sqlite problems

Posted: Wed Dec 09, 2009 8:55 pm
by chris9610
Sorry I did not understand about the error Dialog included, but I will try it.

Re: Sqlite problems

Posted: Wed Dec 09, 2009 9:04 pm
by chris9610
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.

Re: Sqlite problems

Posted: Wed Dec 09, 2009 10:55 pm
by malte
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

Re: Sqlite problems

Posted: Thu Dec 10, 2009 4:08 am
by chris9610
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.

Re: Sqlite problems

Posted: Thu Dec 10, 2009 4:21 am
by chris9610
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.

Re: Sqlite problems

Posted: Fri Dec 11, 2009 5:46 pm
by oliverk
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

Re: Sqlite problems

Posted: Thu Dec 17, 2009 1:57 pm
by chris9610
oliverk:

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

Happy Holidays!