mySql data display blues.....
Posted: Mon Sep 22, 2014 8:35 am
Hi LiveCde/Database Gurus
I urgently and desperately need help. I am still learning LiveCode although I am reasonably confident, but this time I have spend many weeks trying to figure out what and how to do a specific action required for my app.
Here is my situation, stack and card information as well as scripts used on the various elements of my android application.
Here goes.....
Stack Script to deploy on various screen sizes is in the main stack. The code is
on preOpenStack
set the fullScreenMode of this stack to "exactFit"
end preOpenStack
The first card
Here I have a database connection button with the following code in/on it;
on mouseUp
-- use a global variable to hold the connection ID so other scripts can use it
global gConnectionID
-- set up the connection parameters - edit these to suit your database
put "www*********" into tDatabaseAddress
put "fishingpermits" into tDatabaseName
put "*******" into tDatabaseUser
put "*******" into tDatabasePassword
(Please note, for the purposes of this post, I replaced the database address, my username and password with ***)
-- connect to the database
put revOpenDatabase("MySQL", tDatabaseAddress, tDatabaseName, tDatabaseUser, tDatabasePassword) into tResult
-- check if it worked and display an error message if it didn't
-- & set the connection ID global
if tResult is a number then
put tResult into gConnectionID
answer info "Connected to the database." & cr & "Connection ID = " & gConnectionID
else
put empty into gConnectionID
answer error "Unable to connect to the database:" & cr & tResult
end if
go to next card
end mouseUp
The connection to the MySql database is successfull and the application proceeds to the second card. No issues there.
Second Card
On the second card I have a field named "idNumber", a button to display ALL data in the database, and a search button to display a specific dataset based/queried on the idNumber of a specific individual.
The script on the "Display all data" button is
----------------------------------
on mouseUp
-- check the global connection ID to make sure we have a database connection
global gConnectionID
if gConnectionID is not a number then
answer error "Please connect to the database first."
exit to top
end if
-- construct the SQL (this selects all the data from the specified table)
put "permitholders" into tTableName -- set this to the name of a table in your database
put "SELECT * FROM " & tTableName into tSQL
-- query the database
put revDataFromQuery(tab, cr, gConnectionID, tSQL) into tData
-- check the result and display the data or an error message
if item 1 of tData = "revdberr" then
answer error "There was a problem querying the database:" & cr & tData
else
put tData into field "Data"
end if
end mouseUp
Again this script loads ALL data (as requested) from the MySql database successfully, display all data in a field called "data". The application proceeds to the third card. Again no issues there.
The script on the "Search" button to load data based on the id request is as follows and here I have ISSUES and DESPERATELY need help from the LiveCode database gurus.
The Third Card
On this card I have a label field called "ID" where the idNumber as requested must be inserted from the database.
The code on the "Search" button on the second card is as follows:
-- construct the SQL (this selects all the data from the specified table)
put "employee" into tTableName -- set this to the name of a table in your database
put "SELECT * FROM" & tTableName into tSQLQuery
put "WHERE holderID =' '" & pHolderID & " " after tSQLQuery
-- query the database
put revDataFromQuery(tab, cr, gConnectionID, tSQLQuery) into tRecordID
-- check the result and display the data or an error message
if item 1 of tData = "revdberr" then
answer error "There was a problem querying the database:" & cr & tData
else
go to next card
revDatabaseConnectResult(gConnectionID)
set the text of field "emlpoyeeId" of card 1016 to revDatabaseColumnNamed(tRecordID, "employeeId [,tRecordID]")
put holderId into field "ID"
end if
end mouseUp
This is where I issues and desperatley need help.
The application proceeds to the third card, but DOES NOT display the required data from the database. It must be something, which I unfortunately do not see, in my script'
LiveCoders, PLEASE come to my rescue. I am still learning LiveCode....
Steve
I urgently and desperately need help. I am still learning LiveCode although I am reasonably confident, but this time I have spend many weeks trying to figure out what and how to do a specific action required for my app.
Here is my situation, stack and card information as well as scripts used on the various elements of my android application.
Here goes.....
Stack Script to deploy on various screen sizes is in the main stack. The code is
on preOpenStack
set the fullScreenMode of this stack to "exactFit"
end preOpenStack
The first card
Here I have a database connection button with the following code in/on it;
on mouseUp
-- use a global variable to hold the connection ID so other scripts can use it
global gConnectionID
-- set up the connection parameters - edit these to suit your database
put "www*********" into tDatabaseAddress
put "fishingpermits" into tDatabaseName
put "*******" into tDatabaseUser
put "*******" into tDatabasePassword
(Please note, for the purposes of this post, I replaced the database address, my username and password with ***)
-- connect to the database
put revOpenDatabase("MySQL", tDatabaseAddress, tDatabaseName, tDatabaseUser, tDatabasePassword) into tResult
-- check if it worked and display an error message if it didn't
-- & set the connection ID global
if tResult is a number then
put tResult into gConnectionID
answer info "Connected to the database." & cr & "Connection ID = " & gConnectionID
else
put empty into gConnectionID
answer error "Unable to connect to the database:" & cr & tResult
end if
go to next card
end mouseUp
The connection to the MySql database is successfull and the application proceeds to the second card. No issues there.
Second Card
On the second card I have a field named "idNumber", a button to display ALL data in the database, and a search button to display a specific dataset based/queried on the idNumber of a specific individual.
The script on the "Display all data" button is
----------------------------------
on mouseUp
-- check the global connection ID to make sure we have a database connection
global gConnectionID
if gConnectionID is not a number then
answer error "Please connect to the database first."
exit to top
end if
-- construct the SQL (this selects all the data from the specified table)
put "permitholders" into tTableName -- set this to the name of a table in your database
put "SELECT * FROM " & tTableName into tSQL
-- query the database
put revDataFromQuery(tab, cr, gConnectionID, tSQL) into tData
-- check the result and display the data or an error message
if item 1 of tData = "revdberr" then
answer error "There was a problem querying the database:" & cr & tData
else
put tData into field "Data"
end if
end mouseUp
Again this script loads ALL data (as requested) from the MySql database successfully, display all data in a field called "data". The application proceeds to the third card. Again no issues there.
The script on the "Search" button to load data based on the id request is as follows and here I have ISSUES and DESPERATELY need help from the LiveCode database gurus.
The Third Card
On this card I have a label field called "ID" where the idNumber as requested must be inserted from the database.
The code on the "Search" button on the second card is as follows:
-- construct the SQL (this selects all the data from the specified table)
put "employee" into tTableName -- set this to the name of a table in your database
put "SELECT * FROM" & tTableName into tSQLQuery
put "WHERE holderID =' '" & pHolderID & " " after tSQLQuery
-- query the database
put revDataFromQuery(tab, cr, gConnectionID, tSQLQuery) into tRecordID
-- check the result and display the data or an error message
if item 1 of tData = "revdberr" then
answer error "There was a problem querying the database:" & cr & tData
else
go to next card
revDatabaseConnectResult(gConnectionID)
set the text of field "emlpoyeeId" of card 1016 to revDatabaseColumnNamed(tRecordID, "employeeId [,tRecordID]")
put holderId into field "ID"
end if
end mouseUp
This is where I issues and desperatley need help.
The application proceeds to the third card, but DOES NOT display the required data from the database. It must be something, which I unfortunately do not see, in my script'
LiveCoders, PLEASE come to my rescue. I am still learning LiveCode....
Steve