Help! How can I set up a relation between 2 tables in memory?

G

Guest

I've got a situation where I have live data coming in from multiple sources.
I'm able to get it into two tables in RAM.

I have one table called "Providers" and it has a ProviderID and some other
fields.

I have another table called "Services"and it has a ProviderID in it as well
as a ServiceID and some other fields.

I just added data to these tables by using DataRow(0) = <first data item>,
DataRow(1) = <second data item>, etc. ThenI added the row to the table by
using Provider.Rows.Add(datarow)

Did something similar for the 2nd table. Now I want to do a nested
repeater, and I've figured out how to do that, but I'm apparently missing
something on setting up the relations.

How do I set up a relationship between these two tables AT RUNTIME?

I haven't introduced a "Dataset" yet at all. Not sure where to do this, and
I'm not sure what to do. Can someone take pity on me and give me the syntax
for doing a relation when both tables are in memory already?

Thanks in advance!
 
E

Eliyahu Goldin

Have a look into the DataRelation class. That is exactly what you are after.

Eliyahu
 
G

Guest

Yes, I've seen that. Apparently I'm not smart enough to make it work. I
keep getting various errors no matter what I try. I'm very frustrated by the
apparent lack of examples for folks who are just starting out (like me). I
can usually figure out what I need if I can see an example. All of the
examples I've seen use some kind of DataSet.Fill method. I don't think I
need to do that... since I've "manually" populated my lists. I don't even
have a DataSet defined at all... just two tables. Do I *need* to define a
dataset?

Really, I'm just trying to get to the point where I have a nested repeater.
If anyone knows a simpler way to do that with two tables in memory, I'm open
for suggestions.
 
T

Terry Burns

Using the Northwind database, drag orders and order details tables onto the
design canvass and create a dataset, then in code.

Dim relation As New Data.DataRelation("MyRelation",
DataSet11.Orders.OrderIDColumn, DataSet11.Order_Details.OrderIDColumn)

DataSet11.Relations.Add(relation)
 
E

Eliyahu Goldin

Dataset is a sort of a cornerstone in Asp.Net. In many cases you will
benefit a lot from using them. Look at them from the perspective of
organizing your data in the way suitable for your task, regardless how you
obtain the data.

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top