Page 1 of 1

Standalone Database Issue

Posted: Fri Jan 29, 2016 10:54 pm
by smith8867
I have a really odd problem. I have a query to my database to then display the data on the datagrid. When I am in the development area of LiveCode the script works perfectly well, populating the datagrid. However, when I compile the stack in to a standalone package, the button to populate the datagrid doesn't seem to work. I can write to the database, I just can't get the data from the query.

Any ideas as to why this is?
Thanks again guys.

Re: Standalone Database Issue

Posted: Sat Jan 30, 2016 7:10 pm
by quailcreek
Hi,
Need more information. Is this for MAc, Win, iSO? MySQL or SQLite?

Re: Standalone Database Issue

Posted: Sat Jan 30, 2016 9:26 pm
by SparkOut
Just as a guess, I wonder if this is a database issue, or a datagrid issue in the standalone?

There is a quirk to be aware of with datagrids in standalones, maybe this will be something to check? http://lessons.livecode.com/m/datagrid/ ... -data-grid

Re: Standalone Database Issue

Posted: Mon Feb 01, 2016 11:03 pm
by smith8867
quailcreek wrote:Hi,
Need more information. Is this for MAc, Win, iSO? MySQL or SQLite?
I'm using MySQL and windows.

Re: Standalone Database Issue

Posted: Mon Feb 01, 2016 11:11 pm
by quailcreek
So is your Db on a server or local? Post the code that's causing the problem.

Re: Standalone Database Issue

Posted: Tue Feb 02, 2016 7:25 pm
by smith8867

Code: Select all

global connectionID

on mouseUp
   set the DGTEXT of grp "jobData" to empty
  connectToDB
   getDataFromDB
end mouseUp


on connectToDB
   put "**********" into dbAddress
   put "utilsAdmin" into dbUser
   put "*********" into dbPass
   put "jobs" into dbName
   put empty into connectionID
   //
   put revOpenDatabase("MySQL", dbAddress, dbName, dbUser, dbPass) into dbResult
   //
   if dbResult is a number then
      put dbResult into connectionID
   else 
      put empty into connectionID
      put "unable to connect:" & cr & dbResult into field "output"
   end if
end connectToDB

on getDataFromDB
   //Command for selection
   put "SELECT * FROM  jobInfo" into dbSQL
   //
   //Query the database
   put revDataFromQuery(tab,return,connectionID,dbSQL) into dbData
   //
   //Check result and display either the data or error message
   if item 1 of dbData = "revdberr" then
      answer error "There was a problem" & cr & dbData
   end if
   //Populate the datagrid
   set the DGTEXT of grp "jobData" to dbData
end getDataFromDB
It only seems to not work when I compile the code into a standalone package, in the editor it works fine. I've enabled all the MySQL extensions, still doesn't seem to be working.
The database is on a MySQL server.

Re: Standalone Database Issue

Posted: Tue Feb 02, 2016 10:31 pm
by SparkOut
Did you add the dummy substack as mentioned in the lesson I linked?

Re: Standalone Database Issue

Posted: Tue Feb 02, 2016 11:15 pm
by smith8867
Thanks it seems to be working now.

Re: Standalone Database Issue

Posted: Fri May 20, 2016 8:25 pm
by xanant
It seems not to have understood the technique proposed in the post and probably the correct use of the data grid. I made several standalone projects working very well (and no problems) with (one) datagrid and Sqlite / MySQL without adding substack "Data Grid Templates Dud". I wonder: when you create a datagrid (by dragging it from the palette) is already created and added to the main stack a substack "Data Grid Templates nnnnnnnnnnn .."? So Revolution / LiveCode not already found what necessary to add the "revDataGridLibrary" to the standalone, or am I wrong? So far I’ve never needed this method. But I noticed that as long as there is a single datagrid (then a single dragging from palette) everything behaves regularly in the standalone. But if I create multiple cards and put there for example a data grid for each card, any access to datagrid freezes in standalone. In fact, recently creating a project with multiple cards and multiple data grid: if in "IDE" everything is ok, any standalone data grid no longer responds to commands. Is there anything I should be aware of or the method that I use is incorrect or at least partial? Thank you for the possible collaboration
Sandro

Re: Standalone Database Issue

Posted: Fri Jun 03, 2016 10:20 pm
by xanant
HI everyone
no reply?
Having failed to make clear in my previous post, I explain better. With one (or more) datagrid in a standalone everything works regularly (click, sorting, selection, etc.) But of course the data is not saved because the construction of the standalone always run with the technique of 'Splash Screen' leaving NOT selected the option 'Move substacks into individual stackfiles'. In fact, setting it to 'checked' everything in (every) Datagrid freezes. Searching in the Forum found that Larry, long ago (March 9, 2010), in the Post: "Standalone Application for Mac v10.5.8" had the same problem (but I also in EL CAPITAN 10.11.5) and no received solutions. It’s a problem of Datagrid or what? I'm using the method to load the data from SQLite / MySQL (to be read each time at the opening) but is not the most comfortable. Some data would be better saved in one or more 'Custom Property' or somewere else into the substack and so always ready.
Thank you in advance if someone helps me finding a solution.

Re: Standalone Database Issue

Posted: Fri Jun 10, 2016 12:13 pm
by MaxV
A standalone is unchangeable, so every time is opened is like the first time. You can't save anything inside a standalone. This is true for any programming language.
You can save in a separate TXT file on closing your program, for example:

Code: Select all

on CloseStack
 put the dgtext of group "myDatagrid" into URL "file:/home/max/mydatagrid.txt"
 pass closeStack
end CloseStack
During a program running, you can store values wherever you like, for example

Code: Select all

on OpenCard
 set the dgText of group "mydatagrid" to the DGSAVED of me
end OpenCard

on CloseCard
 set the DGSAVED of me to the dgText of group "mydatagrid"
end CloseCard

Re: Standalone Database Issue

Posted: Sun Jun 12, 2016 3:17 pm
by sturgis
IF you want to save some data locally, thats easy enough. You can save a preferences stack to a writable location that contains the properties, and since its external to the standalone is writable. YOu can also use a simple text file, or an xml file or even an sqlite database.

Now, as far as the datagrid.. If you're using the splashstack method, the substack trick is critical and no don't break things down into separate stack files. Basically you want the splashstack to be a "stack runner" but the problem occurs because much of your code will be in the stacks that are NOT part of the splashstack. Which means that the standalone builder doesn't know what to include.If you have the builder search for inclusions and you want to want the datagrid to work you need to add the datagrid dummy stack as mentioned in that lesson to "trick" the builder into including the right script libraries. This can be a problem with other things as well. If your code uses databases but there is no database code as part of the splashstack itself, it may not load the required drivers or libraries.

I _Think_ the more recent versions of LC actually include the datagrid as a select-able script library (the version i'm looking at has it in the list, 8.0.1) so you should be able to go into the standalone settings for your splashstack and manually select the things you want to include. (database, datagrid and whatever else you may need under the script libraries, and mysql under database support)