Android Question How to save primary key from table to the list without showing it

wmardian

Member
Licensed User
Longtime User
Dear All,
Could you please help me ...

I have 2 tables from Database, here are the detail (example);

Employee table:
1. ID as (primary key, auto increment)
2. Name
3. Age

Detail:
1. ID (primary key)
2. Employee_ID
3. Address
4. Email
5. Title
6. Department

By executing query, i want to show the content of Employee Table, so that i want to show, Name and Age in the list. (not with the ID)
And by clicking row in the list, i want to get the ID of the Employee row, and this ID will be used to query the detail.

What i usually do is, executing query, and put "name" and "age" value to the twolineLayout listview. (Because i do not want to show the ID). After that i execute query by using "where" clause with Name and age as parameters to get the ID of first table. Then i use this ID to get the detail on the second table.

My question is:
Is there a simpler solution so that when i populate employee table, i can hide the ID field or creating map between ID and "Name" so that every time i click the listview i can get the ID( without executing query to find the ID). Is there other "listview like" component that can handle this?

Your help is very appreciated
Thanks All..

Best Regards
 

udg

Expert
Licensed User
Longtime User
Hi,

probably the simplest method is to use function ListView.AddTwoLines2(Text1,Text2,ID).
In other words when passing Name/Age data to the ListView, you pass the ID as the optional return vale too.

You may want to read full ListView documentation here.

udg
 
Last edited:
Upvote 0

wmardian

Member
Licensed User
Longtime User
Ups..
Thanks a lot, i did not realize B4A has this function..
Let me try.. sorry for my question..

Thanks a lot
 
Upvote 0
Top