Importing from an SQL database into a table field

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Mikofig
Posts: 5
Joined: Thu Jan 31, 2019 3:00 pm

Importing from an SQL database into a table field

Post 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"
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Importing from an SQL database into a table field

Post 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
Mikofig
Posts: 5
Joined: Thu Jan 31, 2019 3:00 pm

Re: Importing from an SQL database into a table field

Post by Mikofig »

Thank you very much Klaus, that worked as intended. Though how does the use of CR fix the issue?
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Importing from an SQL database into a table field

Post 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)
Post Reply