I have a class that has the following property that is generated by the methods in the constructor.
Public Class clsLoadTables
Private _ds As New DataSet
Public Property ds() As DataSet
Get
Return _ds
End Get
Set(ByVal value As DataSet)
_ds = value
End Set
End Property
Sub New()
Try
loadCSVTableII()
loadXMLFiles(pathMainTable, "MainRMDTable")
loadXMLFiles(pathBeneLifeExp, "pathBeneLifeExp")
Catch ex As Exception
MessageBox.Show(ex.Message)
Throw
End Try
End Sub
End Class
My problem is that I do not want to inherit this class, but I have other classes that need to access the ds DataSet property. If at all possible I would like to not use inheritance and not load my datatable more than once in the program.
Here is my failed attempt to access the property inside another class that is not inheriting clsLoadTables:
Dim tableRow As DataRow = ds.Tables("MainRMDTable").Select(String.Format("age={0}", age.ToString()))(0)
Any ideas on how I can access this dataset that I want to load only once in the program from many classes without using class inheritance or a global module?
You have it as a public property, so you should be able to access it if you have a reference to an instance of the clsLoadTables class.