Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

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.Data.UserData.UserAccess
        test.DBType = UDAL.DataProvider.SqlServer  '********* This SETS the correct value *************

        U_BLL.MuUni.WebProject.Business.UserInfo.User.UniUser("Tom")

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.Data.UserData.UserAccess  '***note the word NEW
            userData = test.GetSystems(RemoveDomain(Identity))
            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.Data.UserData.UserAccess" in BLL. Otherwise, the "set" was working but "Get" was not returning the value that was already "set"...

SOLUTION
Avatar of Hillwaaa
Hillwaaa
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of riyazthad
riyazthad

Farzadw,

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.
Avatar of Camillia

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(Identity)) '*** If I remove shared from DAL, then I have to create an instance
            Return userData


        End Function

***UI:
Dim newUser As New U_BLL.MuUni.WebProject.Business.UserInfo.User()
newUser.UniUser("Tom")

***********I guess it's ok to have the DAL as shared..yes, no?

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial