Getting data in text

My app’s layout and functionality is pretty much finished, now it’s time to connect it with a sqlite database. I have success with reading data from the database in the listbox with contains names, but that same record also has text fields connected to the name in the listbox, like Character Description. Running the code below places the Character Description data from all the records together in the record from a single Character record instead of separated with every record. How should I define this to make it work?

Screenshot 2022-08-12 at 18.14.35

txtcharacterinfo.addtext rs.column("character_description").stringvalue 
txtcharacterinfo.addtext  endofline
1 Like

thanks! It however still places the Character description of all characters together:

You’re getting past the basics, things are going to be less simple from here on out. You should start forming your questions with much more detail and explain the goal of what you’re trying to do. If you ask dead simple questions, you’re going to get dead simple answers and that’s not going to suffice anymore.

You need to associate the character description with the character and load the description when necessary. Currently, you’re loading all the descriptions into the text area when you load the Listbox.

An object-oriented approach would make this much easier, but I’m not certain if that’s within your comfort level. If it is, something like ActiveRecord / ARGen would do wonders for this project. I was tasked with writing pretty much the exact same software some years ago, so I know this approach works.

1 Like

Because you are putting them all into one box.
Did you want them next to the Character Names?
If so, you will need that character listbox to be multi-column.
And put the descriptions into cell 1

Or maybe you only want the description for the select character to appear in that box?
Only you know at this point

Here are some simple solutions

Option 1:When you retrieve all your data populate it in an array. Then use the array to populate the listbox character list. when you click on a character retrieve the description from the array description column. This assumes a 1 to 1 relationship between the array rownumbers and the listbox row numbers

Option 2. Retrieve the characters from the database to populate the listbox and use the rowtag to store the db primary key. clicking on the listbox row use the rowtag to retrieve the description from the database to populate the description text field.

Thanks for the suggestions, Tom. I will try the row tag option first because I worked with that a couple of times. Probably the best solution would be use the database option for all the fields etc, but I have a hard time to wrap my head around this. If the tag option doesn’t work for me, I will continue investigating working with database use for all the objects. If others can learn it, so should I right? :slight_smile: Nothing else to do anyway.

I use the rowtag approach all the time. It means you don’t have to get all the data from every column, just the one’s you’re displaying in the listbox. Then you retrieve all columns for a single row at a time. It greatly reduces database traffic, which can be a big savings if you’re talking to a database over the network.

1 Like

Good to know it’s a good option. So you connect 1 row of a listbox to a database and then the other rows, fields, popup menus etc to tags that are connected to the 1st row of the listbox?

André:

there are a lot of example delivered with Xojo. You may take time to look at them (and the pdf book) if you do not already have done that.

Sometimes there is a trick or two in the example I discover…

Yes, I know. I have read through the topics on xml, Json, database and filetypes to find a way to save and load the user data. Problem is that I cannot see with all these possibilities which one I should use… Knowing which one is the best in my situation would help me focus on one of the options, so now I am mixing and matching so to speak, reading/watching YouTube on all these subjects.

What do you mean by this?

Note that each row in a listbox can have a rowtag (and most of mine do), and that because a rowtag is a Variant, you can put anything you like there. In mine, mostly, the variant contains an instance of a class so I can refer to several items via the same rowtag.

A rowtag belongs to a row, so I don’t know what you mean by “tags that are connected to the 1st row of the listbox”.

And even when your Row have only one Column, yopu also have the CellTag Property where you can also store data.

The best way to store / read the data ?

Let you users choose their own and provide all to them… csv, txt, jason, xml, .sqlite, etc.
How many flavors of Linux can you count (and how many is needed…) when one (or two) is largely enough. :wink:

Thanks Tim, and it does still do a great job. When I moved from Visual Foxpro to XOJO my 1st question ( or maybe 2nd.) was: is there a framework which makes life easier, and where is my ER - Designer.

Answer: I discovered ARGen and Valentina Studio.

And some times later I got my 1st Valentina Bundle, where are much more cooler things ( MBS, Valentina, GraffitiSuite, XDEV Mag, and many more ) are included.

Rainer

I would recommend the database way with SQlite - it is fast, embedded, can be encrypted for security purposes, can be easily changed from within your app etc.

Can be copied nowadays with OCR or better with LiveText !