Camillia
asked on
Why did I have to change my method to "shared"?
1. *** in UserInterface, aspx, I have this:
Dim test As New U_DAL.MyUni.WebProject.Dat a.UserData .UserAcces s
test.DBType = UDAL.DataProvider.SqlServe r '********* This SETS the correct value *************
U_BLL.MuUni.WebProject.Bus iness.User Info.User. UniUser("T om")
2. *** IN BLL, I have this:
Public Class User
Shared Function UniUser(ByVal Identity As String) As ArrayList
Dim userData As New ArrayList
Dim test As New U_DAL.MyUni.WebProject.Dat a.UserData .UserAcces s '***note the word NEW
userData = test.GetSystems(RemoveDoma in(Identit y))
Return userData
End Function
3. ***IN DAL,
Private _DBType As DataProvider
Public Property DBType() As DataProvider
Get
Return _DBType
End Get
Set(ByVal value As DataProvider)
_DBType = value
End Set
End Property
Public Function GetSystems(ByVal userLogin As String) As ArrayList
......
End Function
******I had to change the "GetSystems" to Shared and the "Property" to Shared and remove " Dim test As New U_DAL.MyUni.WebProject.Dat a.UserData .UserAcces s" in BLL. Otherwise, the "set" was working but "Get" was not returning the value that was already "set"...
Dim test As New U_DAL.MyUni.WebProject.Dat
test.DBType = UDAL.DataProvider.SqlServe
U_BLL.MuUni.WebProject.Bus
2. *** IN BLL, I have this:
Public Class User
Shared Function UniUser(ByVal Identity As String) As ArrayList
Dim userData As New ArrayList
Dim test As New U_DAL.MyUni.WebProject.Dat
userData = test.GetSystems(RemoveDoma
Return userData
End Function
3. ***IN DAL,
Private _DBType As DataProvider
Public Property DBType() As DataProvider
Get
Return _DBType
End Get
Set(ByVal value As DataProvider)
_DBType = value
End Set
End Property
Public Function GetSystems(ByVal userLogin As String) As ArrayList
......
End Function
******I had to change the "GetSystems" to Shared and the "Property" to Shared and remove " Dim test As New U_DAL.MyUni.WebProject.Dat
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
All makes sense...But I still cant remove the 'shared' from DAL code. I can remove it from the BLL code. If I remove the "Shared" from the DAL code, then BLL has to create an instance of "GetSystems" which means the "Get property" will be rest...
----This works with removing "shared" from BLL code:
***DAL code:
Private Shared _DBType As DataProvider
Public Shared Property DBType() As DataProvider
Get
Return _DBType
End Get
Set(ByVal value As DataProvider)
_DBType = value
End Set
End Property
Public Shared Function GetSystems(ByVal userLogin As String) As ArrayList
......
End Function
***BLL:
Public Class User
'check user authorization. If user exists,get datbases user can access
'Shared Function UniUser(ByVal Identity As String) As ArrayList
Function UniUser(ByVal Identity As String) As ArrayList
Dim userData As New ArrayList
userData = GetSystems(RemoveDomain(Id
Return userData
End Function
***UI:
Dim newUser As New U_BLL.MuUni.WebProject.Bus
newUser.UniUser("Tom")
***********I guess it's ok to have the DAL as shared..yes, no?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Shared method is part of class rather than instances. So whener you need to share certian functionality or to share common property thru out all instance of classes, u can think of shared fields.
So you dont have create instances, just use with class name.