DataGrid Retrieval Method?

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
newpie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 155
Joined: Sat Jun 29, 2013 11:24 pm

DataGrid Retrieval Method?

Post by newpie » Sun Sep 27, 2015 5:39 pm

Hello, I am new to datagrids and had a question. I have a MySQL database and I already got the following lesson to work:
for a datagrid table.

I read in the comments that someone uses the revDataFromQuery command, similar to what is found on connecting to a SQLite lesson:
.

Code: Select all

on mouseUp
    put databaseGetContactDetails() into field "contact details"
end mouseUp

and add the databaseGetContactDetails function to the card script

function databaseGetContactDetails
    ## Query the database for contact details to be displayed in the field
    put getDatabaseID() into tDatabaseID
    put "SELECT * from contact_details" into tSQL
    put revDataFromQuery(tab,return,tDatabaseID,tSQL) into tRecords
    return tRecords
end databaseGetContactDetails
I would like to learn both ways if possible. I am trying to find an example to use the revDataFromQuery method for inserting data in a datagrid table. Is there an example script of this somewhere that I can study.

Thanks

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: DataGrid Retrieval Method?

Post by SparkOut » Sun Sep 27, 2015 6:57 pm

Datagrids have two "interchangeable" properties for the data they hold.
The dgData is an array of the records. The dgText is a tab-delimited format of the same data.
So given a command revDataFromQuery using (the default) tab and return column and row separators, you can run the query and populate the datagrid simply by

Code: Select all

set the dgText of <your datagrid object reference> to <theReturnedData>

newpie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 155
Joined: Sat Jun 29, 2013 11:24 pm

Re: DataGrid Retrieval Method?

Post by newpie » Tue Sep 29, 2015 1:46 am

Thank you SparkOut for the quick reply. I will try this out.

Post Reply

Return to “Databases”