I have a base class where amongst other code I have declared 2 properties. In my derived class, I get data from the DB and assign the results to the base class properties. This is so when I go back to the base class code, I can access the property values. It allows me to set the values in the derived class but once I go back to the Base class, the values don't exist.
snippets of code sample:
base class:
derived class:
snippets of code sample:
base class:
VB.NET:
Public Class ServiceProcessor
Private mSalesOrderID As Integer = 0
Private mName As String = ""
Friend Property SalesOrderID() As Integer
Get
Return mSalesOrderID
End Get
Set(ByVal value As Integer)
mSalesOrderID = value
End Set
End Property
Friend Property Name() As String
Get
Return mName
End Get
Set(ByVal value As String)
mName = value
End Set
End Property
derived class:
VB.NET:
Public Class DBCaller
Inherits ServiceProcessor
Friend Sub GetData()
Try
Dim Conn As SqlConnection = New SqlConnection(SQLConn)
Dim Cmd As SqlCommand = New SqlCommand("usp_GetData", Conn)
'open the conn and get the datareader
Conn.Open()
Dim Reader As SqlDataReader = Cmd.ExecuteReader()
If Reader.Read Then
MyBase.SalesOrderID = Reader("SalesOrderID")
MyBase.Name= Reader("Name")
End If
Reader.Close()
Conn.Close()