DataSet Collection From Componet Designer

B

Bob Day

Using vs2003, vb.net, msde...

I have Component Designer class that has many datasets in it. I would like
a way to iterate through the DataSets in an instantiation of the Component
Designer class, but don'see any collect available to do that.

' holds Dataset
Dim DS As DataSet

' instantiat component designer class

dim CD as new Component_Designer_Class

' will walk through all Data Sets in Component Designer class

For Each DS In CD.Collection ' *** no such collection command
exists

' code

Next

Any ideas?

Thanks Bob
 
J

Jay B. Harlow [MVP - Outlook]

Bob,
You will need to manually create such a collection to enable enumerating
over it.

You may be able to use Reflection, however I would lean toward manually
defining the collection, simply to avoid picking up all the other child
objects...

Hope this helps
Jay
 
P

Peter Huang

Hi Bob,

Thanks for using Microsoft MSDN Managed Newsgroup. My name is Peter, and I
will be assisting you on this issue.

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to build a dataset
collection in a class.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Here is some code you may take a look.
Imports System.Data
Imports System.Collections
Module Module1
Public Class Component_Designer_Class
Public CS As New Collection
Public Sub New()
Dim i As Integer
For i = 1 To 10
Dim ds As New DataSet
ds.DataSetName = "dataset" + i.ToString
CS.Add(ds)
Next
End Sub
End Class
Sub Main()
Dim ds As DataSet
Dim CD As New Component_Designer_Class
For Each ds In CD.CS
Console.WriteLine(ds.DataSetName)
Next
End Sub
End Module

If you have any concern, please post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Top