An array of datasets/tables ?

  • Thread starter Thread starter Aussie Rules
  • Start date Start date
A

Aussie Rules

Hi,

I have a query that returns a datatset, that contains a table that holds a
bunch of data. One of the columns is "lift_id"

The lift id shows what lift needs to be uses, and for different people using
the application there will be a different number of lifts.

What I need to be able to do is to somehow dynamicly create a number of in
memory tables(as I have no need to keep, and they last only for a few
minutes each time), each containing the data for the lift. For example,
dataset 1 contains all the information for lift 1, dataset 2 contains all
the information for lift 2 and so on. Because the number of lifts will
always be different, then I can't fix the number of datasets.

Once this is done, I have to step through each dataset, and as some lifts
are faster than others, I need to be able to move/step through the dataset
item by item, but always be able to see what lift is doing what item.

Is there away I can do this ?
 
Aussie Rules said:
Hi,

I have a query that returns a datatset, that contains a table that holds a
bunch of data. One of the columns is "lift_id"

The lift id shows what lift needs to be uses, and for different people
using the application there will be a different number of lifts.

What I need to be able to do is to somehow dynamicly create a number of in
memory tables(as I have no need to keep, and they last only for a few
minutes each time), each containing the data for the lift. For example,
dataset 1 contains all the information for lift 1, dataset 2 contains all
the information for lift 2 and so on. Because the number of lifts will
always be different, then I can't fix the number of datasets.

Once this is done, I have to step through each dataset, and as some lifts
are faster than others, I need to be able to move/step through the dataset
item by item, but always be able to see what lift is doing what item.

Is there away I can do this ?
Hope I am not of mark with this but maybe a cursor query can do this. My
assumption is that you know that a dataset can contain more than one table.

So something like (in a stored proc cursor):

1. List all lifts in use
2. For each lift select whatever data for this lift

Hope I don't patronise by saying again, that a dataset can contain many
tables eg

Select * From Lift Where Lift_ID = 1
Select * From Lift Where Lift_ID = 2
will return a dataset with two tables so you access them by:

For Each row as Datarow in ds.Tables(n).Rows 'etc

Hope that helps......
 
I am not sure I exactly know what you are trying to sort through - so sorry
if I misunderstood you.

What about creating a class with a property that is a dataset.

Then instantiate that class with a "List( of T )"...
and keep adding to that one. Here since you can add as many properties as
you need with your class, you can make properties such as "lift id",
"dataset", "some other informaiton what lift id is doing"



that or creating a hash table the id is the LiftID, - something like this:
Dim LiftIDs As New Hashtable
LiftIDs.Add(LiftIDs, dataset)
 
I created this for you... here is the button code:
Hope this helps:


Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim Lifts As New List(Of MyLifts)
Dim myds As New DataSet 'Temp Dataset for example purposes
'Putting data in
For nI As Integer = 1 To 5
Dim TempLifts As New MyLifts
TempLifts.LiftDataset = myds
TempLifts.LiftId = nI.ToString
Lifts.Add(TempLifts)
Next

'Retrieving data
For nI As Integer = 0 To (Lifts.Count - 1)
Dim LiftId As String = Lifts(nI).LiftId
Dim LiftDataset As DataSet = Lifts(nI).LiftDataset
Next

End Sub

and a class I created:
Public Class MyLifts

Private _LiftID As String
Private _LiftDataset As DataSet

Public Property LiftId() As String
Get
Return _LiftID
End Get
Set(ByVal value As String)
_LiftID = value
End Set
End Property

Public Property LiftDataset() As DataSet
Get
Return _LiftDataset
End Get
Set(ByVal value As DataSet)
_LiftDataset = value
End Set
End Property

End Class



====
Cheers'

Miro
 
You can do it, as long as there is only one computer for all lifts, however,
it is a very much horse behind the cart method.

For this is OO (not OOP) created. Simply creating a class for your Lifts
which you put inside a (more) Generic lists makes it a lot easier.

Cor
 
Back
Top