Standalone Database Issue
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Standalone Database Issue
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.
Any ideas as to why this is?
Thanks again guys.
-
- Posts: 746
- Joined: Sun Feb 04, 2007 11:01 pm
- Location: McKenna, WA
Re: Standalone Database Issue
Hi,
Need more information. Is this for MAc, Win, iSO? MySQL or SQLite?
Need more information. Is this for MAc, Win, iSO? MySQL or SQLite?
Tom
MacBook Pro OS Mojave 10.14
MacBook Pro OS Mojave 10.14
Re: Standalone Database Issue
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
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
I'm using MySQL and windows.quailcreek wrote:Hi,
Need more information. Is this for MAc, Win, iSO? MySQL or SQLite?
-
- Posts: 746
- Joined: Sun Feb 04, 2007 11:01 pm
- Location: McKenna, WA
Re: Standalone Database Issue
So is your Db on a server or local? Post the code that's causing the problem.
Tom
MacBook Pro OS Mojave 10.14
MacBook Pro OS Mojave 10.14
Re: Standalone Database Issue
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
The database is on a MySQL server.
Re: Standalone Database Issue
Did you add the dummy substack as mentioned in the lesson I linked?
Re: Standalone Database Issue
Thanks it seems to be working now.
Re: Standalone Database Issue
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
Sandro
Re: Standalone Database Issue
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.
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
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:
During a program running, you can store values wherever you like, for example
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
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
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Standalone Database Issue
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)
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)