Solved

Passing user selection from UI to DAL

Posted on 2006-11-13
9
643 Views
Last Modified: 2012-06-27
1. In my DAL , I have an enum:

Public Enum DataProvider
       SqlServer
    IBM
End Enum

2. In UI, I have a radiobutton that user can select either "sql server" or "IBM".

3. In my DAL right now, I have a class and this line of code ***hardcoded***:
    Dim dbManager As IDBManager = New DBManager(DataProvider.SqlServer)

But I dont want to hardcode "DataProvider.SQlServer". I want to set it based on user's selection. I think I need to use maybe *** class properties *** in my DAL to set the proper enum values...

Is that correct? How can I pass that value and make use of the enum instead of hardcoding the value?

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
9 Comments
 
LVL 6

Expert Comment

by:riyazthad
ID: 17930486
Best option is using Enterprise Library framework. there you can create two database instance like SQlServer and IBM. Then you need to pass this instance name to DAL and you can open specific connection with same code.

Thad
0
 
LVL 8

Accepted Solution

by:
doobdave earned 500 total points
ID: 17930506
Hi,

if I understood this correctly, you would have a property in your DAL cllass, as follows:

Private _DbmsType as DataProvider
Public Property DbmsType as DataProvider
        Get
            Return _DbmsType
        End Get
        Set(ByVal Value As DataProvider)
            _DbmsType = Value
        End Set
End Property

In your UI, you can set the property when the user selects the value.
In the DAL, you can do:

Dim dbManager As IDBManager = New DBManager(DbmsType)

hope this helps,

David

0
 
LVL 7

Author Comment

by:Camillia
ID: 17930514

I have something similar to the enterprise libary...:
http://aspalliance.com/837_Implementing_a_Data_Access_Layer_in_C

and I cant change it at this point....

"Then you need to pass this instance name to DAL "...that's what I want to do...pass user selection to DAL ...should I use "class property" to read from the enum?

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Author Comment

by:Camillia
ID: 17930521
David, i didnt see your comment, let me try that...
0
 
LVL 6

Expert Comment

by:Jayadev Nair
ID: 17930558
Hi,

You can Give value for Enums. like,

Public Enum DataProvider
    SqlServer = 0
    IBM  = 1
End Enum

And while passing value @ constructor, pass like

Dim dbManager As IDBManager = New DBManager(0)

And by result, at your constructor(assuming)

Public Sub New(enValue as DataProvider)
 'When you use enValue variable you will get DataProvider.SQLServer (corresponding enum value of Integer you passed)
End Sub


Thanks.
0
 
LVL 6

Expert Comment

by:riyazthad
ID: 17930559
This is what method I am saying

http://msdn.microsoft.com/msdnmag/issues/05/07/DataPoints/

This is very easy to code.

Thad
0
 
LVL 7

Author Comment

by:Camillia
ID: 17930924
Thad- I cant use the EntLib at this point since we've already coded the DAL using that other link...

Question (using David's method)....

Using David's method, I have this

***DAL ****
 Private _DBmsType As DataProvider
        Public Property DBmsType() As DataProvider
            Get
                Return _DBmsType
            End Get
            Set(ByVal value As DataProvider)
                _DBmsType = value

            End Set
        End Property


        Public Function GetSystems(ByVal userLogin As String, ByVal userSelection As DataProvider) As ArrayList
            'get user's database options
            Dim retVal As New ArrayList

            Dim dbManager As IDBManager = New DBManager(DBmsType)
             ..............
            Return retVal

        End Function

***BLL ****

  Shared Function UniUser(ByVal Identity As String, ByVal userSelection As U_DAL.DataProvider) As ArrayList

            Dim userData As New ArrayList


            Dim test As New U_DAL.MyUni.WebProject.Data.UserData.UserAccess
            userData = test.GetSystems(RemoveDomain(Identity), userSelection)


            Return userData


        End Function

***********Now, I in User Interface (aspx page), I get the value of the radiobutton...but that's a string..how should UserInterface (aspx) page/radioButton ....pass to the BLL and then to DAL?? **************
0
 
LVL 7

Author Comment

by:Camillia
ID: 17931279


 Basically, how do "In your UI, you can set the property when the user selects the value" and now pass it to BLL and then to DAL?
"
0
 
LVL 7

Author Comment

by:Camillia
ID: 17931570
*** Getting close but still have a problem ****

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
        'check user authorization. If user exists,get datbases user can access
        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
            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
            'get user's database options
            Dim retVal As New ArrayList

            Dim dbManager As IDBManager = New DBManager(DBType)
               ..........
            Return retVal

        End Function

*********BUT : Dim dbManager As IDBManager = New DBManager(DBType) gets the FIRST value in the enum. It looks like it gets reset by the time it gets to DAL. "DBType" goes to the property but then the "set" value is reset...

any ideas what i'm dong wrong?
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

626 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