I do not know how to formulate the question correctly, so please bear with me ...
I have 3 classes: server, database and table. Each class has a Name property. As I want it to work, each server can have multiple databases, and each database can have multiple tables. Therefore, in the Server class, I have this property.
Private _databases As List(Of Database)
Public Property Databases() As List(Of Database)
Get
Return _databases
End Get
Set(ByVal value As List(Of Database))
_databases = value
End Set
End Property
And I have something similar in the Database class for tables. Now this works fine, because I can do something like this to get all the databases on the server.
For Each db In s.Databases being the server object
Debug.Print(db.Name)
Next
I would like to expand these classes. I want the server class to handle all the connection information, and I would like other classes to use the connection information with the server class in them.
, . , serverclass.connectionstring . . ?
, .
Public Class Server
Private _name As String
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Private _databases As List(Of Database)
Public Property Databases() As List(Of Database)
Get
Return _databases
End Get
Set(ByVal value As List(Of Database))
_databases = value
End Set
End Property
End Class
'-----New class
Public Class Database
Private _name As String
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Private _tables As List(Of Table)
Public Property Tables() As List(Of Table)
Get
Return _tables
End Get
Set(ByVal value As List(Of Table))
_tables = value
End Set
End Property
'This is where I need help!
Private Sub LoadTables ()
dim connectionstring as string = server.connectionstring 'Possible?
'Do database stuff
End Class
!