Standalone with mySQL

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Standalone with mySQL

Post by bsouthuk » Tue Aug 31, 2010 4:21 pm

Hi

I have built a standalone that works with my mySQL database but when I seperate my application from the Windows folder and save it to my desktop it doesnt connect to my database. However, if I take the 'External' folder from the Windows folder and save that to my desktop then it works fine.

Why do I have to have the External folder on my desktop along with my App for it to work?

I'm about to send this to various customers but is there a way they can have just to App sitting on their desktop and not the External folder with the Database_Drivers in? JUst seems as bit silly having to get them to do this.

What the best way would you say?

Thanks

Daniel

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

Re: Standalone with mySQL

Post by Klaus » Tue Aug 31, 2010 4:36 pm

Hi Daniel,
bsouthuk wrote:Hi

I have built a standalone that works with my mySQL database but when I seperate my application from the Windows folder and save it to my desktop it doesnt connect to my database. However, if I take the 'External' folder from the Windows folder and save that to my desktop then it works fine.

Why do I have to have the External folder on my desktop along with my App for it to work?
As you experienced, your app NEEDS these external folder to be able to connect to the mySQL database.
bsouthuk wrote:...but is there a way they can have just to App sitting on their desktop and not the External folder with the Database_Drivers in?
In one word: NO
bsouthuk wrote:What the best way would you say?
Just deliver a complete folder including your app and the externals folder and tell your customers to not remove the externals folder.


Best

Klaus

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Re: Standalone with mySQL

Post by bsouthuk » Tue Aug 31, 2010 4:54 pm

Thanks again for your help Klaus.

I have been searching everywhere for some tips or lessons/tutorials for generating reports from my datagrid. Is this easily possible?

I have developed an application that pulls data from mySQL database and displays it in a datagrid which is great as you can sort ID, by name and date etc. However, if I want only names beguinning with A for example to be displayed in the datagrid what do I need to do?

The main one is that I have a 'Date' collumn and would like to generate a report showing all rows within a date period. So a user would be able to type in a 'from' date in a field and a 'to' date in another field, thus displaying all rows in the datagrid within the dates specified.

Are their scripts or tutorials to help me with this that you know of?

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

Re: Standalone with mySQL

Post by Klaus » Tue Aug 31, 2010 5:52 pm

Hi Daniel,

do you mean you need the SQL command to do what you need?
Only name starting with A:
select * from YOUR_TABLE where NAME like "A%"

In between dates, here you need to convert the user input to the SQL dateformat first -> YYYY-MM-DD!
select * from YOUR_TABLE where startdate >= "you converted start date here" AND enddate <= "your converted end date here"

You get the picture :D

Here is an URL that got me started with SQL: http://www.w3schools.com/sql/default.asp

If you want to filter the data that is already in the datagrid, then I have no idea.
But check the datagrid docs, I am sure you will find an answer there.


Best

Klaus

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Re: Standalone with mySQL

Post by bsouthuk » Tue Aug 31, 2010 6:36 pm

Brilliant Klaus thanks.

I have the following code in rev button:

on mouseUp
revSetSQLOfQuery "Query 1", "select * from Test where Date >= '2010-08-01' AND Date <= '2010-08-20'"
end mouseUp

This works which is great but the From and To dates I want to be able to have users enter dates in Rev fields 'From' and 'To'. How do I then alter the code so that this works?

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

Re: Standalone with mySQL

Post by Klaus » Tue Aug 31, 2010 6:53 pm

Hi Daniel,

depends on how the user enters the dates!
I would create functions for converting dates to mysql format and back

Example: user entered 08/01/2010

Code: Select all

function date2mysql tDate
  set itemdel to "/"
  return item 3 of tDAte & "-" & item 2 of tDate & "-" item 1 of tDate
end date2mysql
Need of course some finetuning like adding leading 0 if necessary, but you get the picture.

Then you could script:
...
revSetSQLOfQuery "Query 1", ("select * from Test where Date >= '" & date2mysql(fld "startdate") &"' AND Date <= '" & date2mysql(fld "enddate"))
...

Best

Klaus

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Re: Standalone with mySQL

Post by bsouthuk » Tue Aug 31, 2010 7:15 pm

All starting to make sense now thanks Klaus.

Its not a problem with the / so I have taken out date2mysql but when I try with the following script:

...
revSetSQLOfQuery "Query 1", ("select * from Test where Date >= '" & (fld "startdate") &"' AND Date <= '" & (fld "enddate"))
...

For some reason it clears my field list completely even though I have the correct dates in my fields.

I have tried taking out some " and ' but still does not work - can you spot anything here?

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

Re: Standalone with mySQL

Post by Klaus » Tue Aug 31, 2010 7:45 pm

Hi Daniel,

I have no idea how you store your dates in the database, but I think you definded these database fields as DATE, right?
Then you MUST convert the user input first before using it in your query!

Or do your user enter the dates in the correct mySQL form YYYY-MM-DD? I doubt :D
And that maybe the reason why your query returns NADA and thus clears your fields.


Best

Klaus

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Re: Standalone with mySQL

Post by bsouthuk » Wed Sep 01, 2010 5:04 pm

Got it!

Brilliant thank you Klaus - you are genius, I hope you get paid lots of money!

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

Re: Standalone with mySQL

Post by Klaus » Wed Sep 01, 2010 5:47 pm

Hi Daniel,
bsouthuk wrote:Got it!
Took a while 8)
bsouthuk wrote:Brilliant thank you Klaus - you are genius
Yes, I know. :D
bsouthuk wrote:.. I hope you get paid lots of money!
Hmm, unfortunately not.
I am currently unemployed and its hard to get a job when you are 54 years old and one of the
only things you are good at is an "unknown" (to the job market) programming language.


Best

Klaus

EDIT:
P.S.
I am available for Rev contract work, Rev project assistance and Rev coaching.
Please spread the word :)

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Re: Standalone with mySQL

Post by bsouthuk » Wed Sep 08, 2010 9:43 pm

Hi Klaus

I have only just noticed this message.

I will be looking for help/support with my work very soon - I am building a small customer base with my application and someone with your expertise will be of value as I am just kinda learning as I go on here.

I will be in touch!

Post Reply