MySQL to Data Grid

Creating desktop or client-server database solutions?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
Posts: 2
Joined: Sun Aug 28, 2016 8:04 am

MySQL to Data Grid

Post by iambath » Sun Aug 28, 2016 8:38 am

Good day! :D I'm a newbie in livecode. I'm using MySQL as my database.
I figured out how to connect LC to MySQL but i need help to display my records from my database to the DATA GRID.
I don't know how to display records in the datagrid.

for example i have DbName as my database name, Users as my Table name. I have 2 fields: ID and NAME.
I have myGrid as my DATA GRID name with two columns: ID and NAME.

I need to display all the record in my database to my myGrid and It will be nice if I can UPDATE and DELETE some records from the DATAGRID.
I try to learn programming using Livecode.
Thanks and Good day! :D

Posts: 11497
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany

Re: MySQL to Data Grid

Post by Klaus » Sun Aug 28, 2016 2:46 pm

Hi iambath,

1. welcome to the forum! :D

2. I suppose the data from your db comes in "standard" TAB and CR delimited text?
then you can simply (supposed you have a datagrid of type TABLE!):

Code: Select all

set the dgtext of grp "your datagrid here..." to variable_filled_with_data_from_sql_query
## You get the picture! 
"the dgtext of grp datagridXYZ" is always in TAB and CR delimited text format and
can be easily used with TABLE datagrids like here.
"the dgdata of grp datagridXYZ" in an ARRAY in format:
tArray[1]["name of column1"]
tArray[1]["name of column2"]
tArray[N]["name of column1"]
tArray[N]["name of column2"]
But both can be used to get and set data in a TABLE and FORM datagrid.

Check these pages and download the datagrid documantation as PDF from that page:
Hint: the download link is hidden in tiny fontsize on the left side under "Topics".

And don't hesitate to come back with more questions!
Unfortunately datagrids are the most complex objects EVER in Livecode! :D



Posts: 2
Joined: Sun Aug 28, 2016 8:04 am

Re: MySQL to Data Grid

Post by iambath » Mon Aug 29, 2016 5:30 am

Thanks for the answer Klaus :D

I can display my records from the database but i am using a fields, the problem i don't know how to update or delete it from the field.
That's why I decided to used DATAGRID unfortunately like you said its complex :shock: .
I don't have example source code to study it(MySQL-LIVECODE using DATAGRID table). Mostly they are using SQLite.
It will be a big help if I can study sample stack about it. Even it has only 1 column.

Thank you and Good day! :)

Posts: 1575
Joined: Tue May 28, 2013 2:20 pm
Location: Italy

Re: MySQL to Data Grid

Post by MaxV » Fri Sep 02, 2016 5:14 pm

Livecode Wiki:
My blog:
To post code use this:

Post Reply

Return to “Databases”