Programmatically Change Connection String in Data Access Layer

Posted on 2011-10-15
Last Modified: 2012-05-12
I'm providing snapshots - hopefully it will help.  I have picked up an application from another developer.  The connection string was put in the DAL.  I have a requirement to change the connection string per HIPPA laws.  There are two connection strings in the webconfig file.

To make it easy - when the user logs in the first connection string needs to be used and passed to the DAL.  After login I need to pass the second connection string to the DAL and use it.

I put a breakpoint in the DAL.Setup but it does not stop and I receive an error in the Login Class.

Any idea?
Question by:CipherIS
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    You've got a private variable _connstr which holds the connection string, why not create a public function that would allow you to pass in a new connection string? Perhaps:

    Public Sub SetConnectionString(ByVal newConString As String)
        Me._connstr = newConString
    End Sub

    Open in new window

    You call this as needed in the code outside of your DAL.
    LVL 1

    Author Comment

    didn't work
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    Perhaps you could elaborate on what you did exactly?
    LVL 14

    Expert Comment

    by:nishant joshi
    DAL ???  is it table adapter...?
    LVL 1

    Accepted Solution

    I resolved it.  I made the method a shared method and the variables a shared method

    LVL 1

    Author Closing Comment

    I resolved it.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Suggested Solutions

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now