Need help retrievig data from my query!..

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

Need help retrievig data from my query!..

Post by snop21 » Sun Feb 02, 2014 4:04 pm

Good Day Livecoders,

I need your help. I have a query my problem is how can I able to pass it to the txt field?

I have 2 columns in my table named "name and address"

I have query here's my script

local Ldisplay
local Tdisplay
put "select * from contact_details where email = 'dede'" into ldisplay
put revdatafromQuery (,,gConnectionID,ldisplay) into display

I am successful displaying in datagrid but i want to put it the data into the txt field.

from my query into the txtfield.

Need your help.

Any help will very much appreciated.

Thanks Livecoders.. :))

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Need help retrievig data from my query!..

Post by Klaus » Sun Feb 02, 2014 4:33 pm

Hi Snop21,

what about:
...
put revdatafromQuery (,,gConnectionID,ldisplay) into display
put display into fld "your field here"
...
Since "revdatafromQuery" will return just text, you can simply put this into a field!
:D

Best

Klaus

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

Re: Need help retrievig data from my query!..

Post by snop21 » Sun Feb 02, 2014 4:52 pm

-klaus

Thanks klaus,

I tried it but it display all the data from my query into the a single txtfield I want to display it one column per txtfield.
---sample my query "select name,email from contacts where name = 'snop21'"

the result
txtfield1 == the value of name from my query
txtfield2 == the value of email from my query

- Thanks

-snop21

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Need help retrievig data from my query!..

Post by dunbarx » Sun Feb 02, 2014 4:55 pm

Hi.

Is it possible that you are trying to put an array into a text field? This will not work. The array must first be converted into the clear, likely with the "combine" command.

If you already have your data in a dataGrid, the same issue applies, so you might take the "dgData" from the DG, since this is also clear data, not an array, like the dgData would be.

Craig Newman

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Need help retrievig data from my query!..

Post by dunbarx » Sun Feb 02, 2014 4:58 pm

I see.

Why not parse your data according to the delimiters it is formatted with? I assume these are tab and return? You can loop through each line quickly and extract the item of interest from each line. These will form the "column" you want.

Craig

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

Re: Need help retrievig data from my query!..

Post by snop21 » Sun Feb 02, 2014 5:02 pm

Hi Craig,

I am new in Livecode that's why I am getting difficulty honestly I don't have an Idea how to do it regarding to your suggestion. But thanks anyway.. :))

- snop21

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Need help retrievig data from my query!..

Post by Klaus » Sun Feb 02, 2014 5:11 pm

Hi snop21,
snop21 wrote:I tried it but it display all the data from my query into the a single txtfield
but that was your question! 8)
...i want to put it the data into the txt field...
:D

What "revdatafromquery" returns is TEXT, as I already mentioned, in the format:
1 record per LINE and the fields delimited by TAB in each line in the order as you queried them.

So this:
...
select name,email from contacts where name = 'snop21'
...
will probably return ONE line/record, so you can do this:
...
put revdatafromQuery (,,gConnectionID,ldisplay) into display
set itemdel to TAB
put item 1 of display into fld "name"
put item 2 of display into fld "email"
...

Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Need help retrievig data from my query!..

Post by dunbarx » Sun Feb 02, 2014 5:31 pm

Something like this. In a button somewhere:

Code: Select all

on mouseUp
   put "a" & tab & "b" & tab & "C" & return & "z" & tab & "x" & tab & "b" & return & "h" & tab & "j" & tab & "k" into tData
   set the itemdelimiter to tab
   repeat with y = 1 to the number of lines of tData
      put item 2 of line y of tData into line y of tColumn
   end repeat
   answer tColumn
end mouseUp
Craig

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

Re: Need help retrievig data from my query!..

Post by snop21 » Mon Feb 03, 2014 7:43 am

-Klus

Got it.. Thank you.. :))

Kudos..!

-snop21

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Need help retrievig data from my query!..

Post by Klaus » Mon Feb 03, 2014 1:25 pm

snop21 wrote:-Klus
KLAUS, my name is KLAUS!
KLAUS! &#*¢¢$$"§ 8)

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

Re: Need help retrievig data from my query!..

Post by Simon » Mon Feb 03, 2014 8:50 pm

What a Majer mistake! :D

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

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

Re: Need help retrievig data from my query!..

Post by snop21 » Tue Feb 04, 2014 6:57 am

-Klaus

it's a mortal sin.. hehe :))

I am Very Sorry.. Didn't Noticed I spelled it wrong.

-snop21

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Need help retrievig data from my query!..

Post by Klaus » Tue Feb 04, 2014 1:21 pm

Simon wrote:What a Majer mistake! :D
Simon
Very funny, Sayman! :D

Post Reply

Return to “Mac OS”