Help query displaying in datagrid..

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
snop21
Posts: 90
Joined: Mon Jan 20, 2014 2:54 pm

Help query displaying in datagrid..

Post by snop21 » Tue Jun 10, 2014 3:30 pm

Good Day, Guys..

I am encountering a problem with my query.. I have a 14 columns in my database and it has 4 data on it. I query it and display it to datagrid my problem was
in the datagrid it doesn't return the 4 rows of my database supposed to be it will return the 4 rows. I attached the screen shot.

Any help is very much appreciated.

my script
---------------

put revOpenDatabase("mysql","sql5.freemysqlhosting.net","sql542966","sql542966","sG4!dS3!") into conn1
put "select * from temptransaction" into query
put revDataFromQuery(,,conn1,query) into dt
set the dgText of group "Datagrid 1" to dt
revCloseDatabase conn1
put empty into conn1

------------------

Thank You, Livecoders..

Regards

-snop21
Attachments
Image.png
Screenshot

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Help query displaying in datagrid..

Post by Simon » Tue Jun 10, 2014 3:39 pm

Hi snop21,
From the lesson http://lessons.runrev.com/m/datagrid/l/ ... -with-data
pText is assumed to be a collection of data where each row is delimited by the return character and each item is delimited by a tab.
You dropped the columnDelim rowDelim from revDataFromQuery.

Is that enough?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Help query displaying in datagrid..

Post by bangkok » Tue Jun 10, 2014 4:24 pm

I would say : your data contains CR and/or LF.

With

Code: Select all

put revDataFromQuery(,,conn1,query) into dt
LiveCode will use (per default) tab as column delimiter and return (CR) as row delimiter.

So if one of your column contains a CR, LiveCode will see "new row". Hence the twisted display.

Solution :
-clean the data you record in your database, by removing CR etc.
-or :

Code: Select all

put revDataFromQuery(,"|",conn1,query) into dt
replace CR with " " in dt
replace LF with " " in dt
replace "|" with CR in dt
set the dgText of group "Datagrid 1" to dt

Post Reply