Programatically changeing a SQLConnection's Connection String. What's the best way?

  • Thread starter Thread starter David Hearn
  • Start date Start date
D

David Hearn

I have a laptop that I am developing my ASP.NET app on while in the office
and I connect to our SQL database located on the network in the office.
However, when I take the machine home, I connect to a local copy of the
database that is on my machine. I have added a key in the web.config file
which I access and it works for all of the manually written connections that
I have but I have a few SQL Connections that I have dragged and dropped from
the toolbox onto a few of my web forms. These have the connection string
hard coded into the page. My question is how do I change the strings for
these connections so that they will work no matter which database copy I am
using?

Thanks in advance!
 
If the entire connection string is the same except for the "Data Source"
keyword, you can use an alias (with SQL Server) to point to redirect where
the server name used in the connection string is addressed.
I use "DemoServer" for my samples and suggest my readers create an alias
that points this name at their own server.

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Back
Top