Solved

Passing user selection from UI to DAL

Posted on 2006-11-13
9
639 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
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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

831 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