Results 1 to 6 of 6

Thread: How to change connection string dynamically across ALL pages in VS.NET?[Resolved]

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2005
    Posts
    45

    Resolved How to change connection string dynamically across ALL pages in VS.NET?[Resolved]

    Hi,
    I have many ASP.NEt pages. I use the SQLConnection from the toolbox.
    I move my project from one PC to another.

    Now, i need a way to dynamically change the conenction string for the SQLConnection across all the pages in my project.

    Who has methods to my problem?
    Last edited by aspfan; Mar 14th, 2005 at 08:08 PM.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: How to change connection string dynamically across ALL pages in VS.NET?

    Store it in web.config.

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2005
    Posts
    45

    Re: How to change connection string dynamically across ALL pages in VS.NET?

    Quote Originally Posted by mendhak
    Store it in web.config.
    Is that the only step.
    I think i also need to "map" the SqlConnection in each of the page to the setting in web.config right?

    How do i achive that ?

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2005
    Posts
    45

    Re: How to change connection string dynamically across ALL pages in VS.NET?

    Ok, i have solved it. thanks mendhak.
    BUT, is there a piece of code or software that could help me change the connection string in web.config ?

    My idea is, I have a project build on machine A.
    I want to deploy that project on machine B.
    So, i need to change the connection string of the project if the project was to be hosted on machine B.

    Is there easier way to accomplish this?

    Thanks for ur time

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: How to change connection string dynamically across ALL pages in VS.NET?

    That's about as easy as it gets and is one of the most widely used methods.

  6. #6

    Thread Starter
    Member
    Join Date
    Feb 2005
    Posts
    45

    Re: How to change connection string dynamically across ALL pages in VS.NET?

    Quote Originally Posted by mendhak
    That's about as easy as it gets and is one of the most widely used methods.
    Alright.
    Thanks for your help. You save a lot of my time.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width