populating listview from multiple tables

jennann

Member
Joined
Apr 11, 2012
Messages
9
Location
Davao City, Philippines
Programming Experience
Beginner
Hi!..
Is it possible to populate the listview from multiple tables?.
I have a listview that I need to populate but in an order that is necessary.
I would like to ask for an idea how..
thank you!
 
You can populate a ListView with whatever data you want. The ListView has no concept of where the data comes from. It simply displays whatever Strings you provide it, with no interest in where those Strings came from. If you want the data to come from multiple database tables then you need to retrieve data from multiple database tables. You haven't told us anything more about the relationship between the tables and how you want the data mapped to the ListView so we can;t tell you any more than that without guessing.
 
I'm sorry for not clarifying my question.
I would like to cite an example, for instance I have tables named YearbookTable and CustomerTable.
In YearbookTable, I have YearbookName, YearbookType, and DateReceived. While in CustomerTable, I have CustomerName, and Customer Address.
In my Listview table, I would only populate it through these two tables, as mentioned, but with specific records only, such as, YearbookName, YearbookType, and CustomerName.
I would like to ask if what method or how would I do this.
Thank You!
 
This really has nothing to do with the ListView then. You will be retrieving the data into a single DataTable and then looping through that to add one item to the ListView per row. You simply need to write the appropriate query to generate a single result set from multiple tables. As you haven't told us what the actual relationship is between the tables I cannot be specific, but it will be something like this:
VB.NET:
SELECT p.Column1, c.Column2
FROM Parent p INNER JOIN Child c
ON p.ParentID = c.ParentID
Parent.ParentID is a primary key and Child.ParentID is a foreign key, thus defining the relationship.
 
Use the Advanced editor, click the little VB button and specify "vb.net" (without quotes) as the option. Just make sure that you post, as closely as you can tell, all the relevant code and no irrelevant code.
 
Back
Top