Get Dataset from Form created by DirectCast

109 Views Asked by At

I have this code that I got from somewhere that calls a form based on a certain variable:

Dim frm as String = "Form1"    'this may vary depending on a certain function
Dim objType As Type = Type.[GetType]("project." & frm)
Dim objForm As Form = DirectCast(Activator.CreateInstance(objType), Form)

Now on Form1 (and all the forms that can replace Form1), i have there a dataset with a name ds. So, when I access ds directly, it works.

Dim newds = Form1.ds

Now what I want is to access ds using objForm.

I have tried:

objForm.Controls.Find("ds")

But is doesn't work. I think it is because Dataset is part of System.Data

0

There are 0 best solutions below