Retrieve one record, contents into text fields

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

neatgadgets
Posts: 17
Joined: Sat Dec 21, 2013 12:14 pm

Re: Retrieve one record, contents into text fields

Post by neatgadgets » Sat Oct 11, 2014 1:35 am

Yes, as I said, the only difference in the code was the delimiter in the line

Code: Select all

  put  revdatafromquery(,,sDbId,tSql) into tData
was set in my code.

There are no commas in my data. I put a simple test set of data. Has anyone actually used MySQL with LiveCode? And what version of MySQL has LiveCode been tested against?

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Retrieve one record, contents into text fields

Post by sturgis » Sat Oct 11, 2014 1:46 am

EDIT: reread the first one where you put this.

Code: Select all

   -- construct the SQL (this selects all the data from the specified table) 
   put "properties" into tTableName    -- set this to the name of a table in your database
   put "SELECT * FROM " & tTableName into tSQL
   
   -- query the database
   put revDataFromQuery(tab, cr, gConnectionID, tSQL) into tData
   put item 2 of tData into fld "fldStreetNumber"
   put item 3 of tData into fld "fldStreetName"
And you said you tried it modified like this:

Code: Select all

   -- construct the SQL (this selects all the data from the specified table) 
   put "properties" into tTableName    -- set this to the name of a table in your database
   put "SELECT * FROM " & tTableName into tSQL
   
   -- query the database
   put revDataFromQuery(tab, cr, gConnectionID, tSQL) into tData


-- Added lines
   set the itemdelimiter to tab -- so that lc knows how to break up items
   put tData -- (so that you can see all your data in the message box to get visual feedback of what is actually being returned) 
-- End Added Lines
   put item 2 of tData into fld "fldStreetNumber"
   put item 3 of tData into fld "fldStreetName"
  

And yeah, lots of people use mysql with livecode. As far back as I can remember in fact. Not sure when mysql support first appeared but its been in there a long time. However, lots of changes are going on right now, so its possible something has snuck in. What version of lc are you using? I'll grab the same and see if I can duplicate the problem.

neatgadgets
Posts: 17
Joined: Sat Dec 21, 2013 12:14 pm

Re: Retrieve one record, contents into text fields

Post by neatgadgets » Sat Oct 11, 2014 4:36 am

Code: Select all

   put "properties" into tTableName    -- set this to the name of a table in your database
   put "SELECT * FROM " & tTableName into tSQL
   
   -- query the database
   put revDataFromQuery(tab, cr, gConnectionID, tSQL) into tData

set itemdel to TAB
put tData

   put item 2 of tData into fld "fldStreetNumber"
   put item 3 of tData into fld "fldStreetName"
I note you had

Code: Select all

set the itemdelimiter to tab
I tried that also, same result.

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

Re: Retrieve one record, contents into text fields

Post by Klaus » Mon Oct 13, 2014 3:25 pm

Hi neatgadgets,

the syntax is definitively correct! So maybe there is something wrong your data or database or whatever!
I could offer to take a look at your stack.

If that is OK, then:
1. create a new field somewhere in your stack and put the result of ONE query into this field, so no need to access your database!
2. Then you can delete all the database access stuff, like passowrd and log-in data.
3. Send me that "stripped-down" stack -> klaus AT major-k.de


Best

Klaus

Post Reply

Return to “Databases”