Page 1 of 1

Importing from an SQL database into a table field

Posted: Thu Mar 07, 2019 3:43 pm
by Mikofig
I have been trying to import rows from a database into a table in order to create a scoreboard. I have managed to import the data but it only gets displayed in one row of the table rather than two rows even though I specified a return after the data.


I have a field (Searchvalues) that contains the search value as a test and the query returns two rows as it should. This is probably not the best way of doing it so any tips would be much appreaciated

Code: Select all

put "SELECT * FROM `scores` WHERE username LIKE '%" & line 1 of field "Searchvalues" & "%' OR Hero LIKE '%" & line 1 of field "Searchvalues" &"%'" into tSQL
   put revDataFromQuery(tab,tab, gConnectionID, tSQL) & return after field "scores"

Re: Importing from an SQL database into a table field

Posted: Thu Mar 07, 2019 3:51 pm
by Klaus
Hi Mikofig,

well no wonder if you define also a TAB for the line delimiter:

Code: Select all

...
put "SELECT * FROM `scores` WHERE username LIKE '%" & line 1 of field "Searchvalues" & "%' OR Hero LIKE '%" & line 1 of field "Searchvalues" &"%'" into tSQL
## put revDataFromQuery(tab,tab, gConnectionID, tSQL) & return after field "scores"
put revDataFromQuery(tab,CR, gConnectionID, tSQL) & return after field "scores"
...
Best

Klaus

Re: Importing from an SQL database into a table field

Posted: Thu Mar 07, 2019 4:08 pm
by Mikofig
Thank you very much Klaus, that worked as intended. Though how does the use of CR fix the issue?

Re: Importing from an SQL database into a table field

Posted: Thu Mar 07, 2019 4:28 pm
by Klaus
These two parameters TAB and CR tell LC to separate the database fields with a TAB and each record with a CR, so you get one record per line!

Please lookup "revDataFromQuery()" in the dictionary for further infos.
It is important that you fully understand what you are doing! 8)