Page 1 of 1

Need help retrievig data from my query!..

Posted: Sun Feb 02, 2014 4:04 pm
by snop21
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.. :))

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

Posted: Sun Feb 02, 2014 4:33 pm
by Klaus
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

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

Posted: Sun Feb 02, 2014 4:52 pm
by snop21
-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

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

Posted: Sun Feb 02, 2014 4:55 pm
by dunbarx
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

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

Posted: Sun Feb 02, 2014 4:58 pm
by dunbarx
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

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

Posted: Sun Feb 02, 2014 5:02 pm
by snop21
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

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

Posted: Sun Feb 02, 2014 5:11 pm
by Klaus
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

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

Posted: Sun Feb 02, 2014 5:31 pm
by dunbarx
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

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

Posted: Mon Feb 03, 2014 7:43 am
by snop21
-Klus

Got it.. Thank you.. :))

Kudos..!

-snop21

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

Posted: Mon Feb 03, 2014 1:25 pm
by Klaus
snop21 wrote:-Klus
KLAUS, my name is KLAUS!
KLAUS! &#*¢¢$$"§ 8)

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

Posted: Mon Feb 03, 2014 8:50 pm
by Simon
What a Majer mistake! :D

Simon

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

Posted: Tue Feb 04, 2014 6:57 am
by snop21
-Klaus

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

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

-snop21

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

Posted: Tue Feb 04, 2014 1:21 pm
by Klaus
Simon wrote:What a Majer mistake! :D
Simon
Very funny, Sayman! :D