Solved

Why did I have to change my method to "shared"?

Posted on 2006-11-13
4
220 Views
Last Modified: 2010-04-23
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"...

0
Comment
Question by:Camillia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 16

Assisted Solution

by:Hillwaaa
Hillwaaa earned 250 total points
ID: 17934370
Hi Farzadw,

You had to change the GetSystems to shared as you have "UniUser" set as Shared.  The User class is therefore never instanciated, which means that when GetSystems is called it has to be as a Shared method as well.

As an alternative, you could create a new User object in UserInterface like

Dim newUser = U_BLL.MuUni.WebProject.Business.UserInfo.User()

and change the UniUser function declaration to:

Public Class User
        Function UniUser(ByVal Identity As String) As ArrayList 'Note that it is not shared


Then you could call:

newUser.UniUser("Tom")

Cheers!
0
 
LVL 6

Expert Comment

by:riyazthad
ID: 17934859
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.
0
 
LVL 7

Author Comment

by:Camillia
ID: 17935017

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?

0
 
LVL 6

Accepted Solution

by:
riyazthad earned 250 total points
ID: 17935207
I think your code is good have shared method. This is best place to create as shared method. So go ahead with shared in DAL.

Enjoy coding

Thad
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question