Re: Static shared data connection provider?
From: Ken Cox [Microsoft MVP] (BANSPAMken_cox_at_sympatico.ca)
Date: 04/04/04
- Next message: Bill Borg: "Re: Compiled Code accessing New User Controls at runtime"
- Previous message: cgia: "How to deploy an application disabling the back button of the browser?"
- In reply to: Jon Davis: "Static shared data connection provider?"
- Next in thread: Jon Davis: "Re: Static shared data connection provider?"
- Reply: Jon Davis: "Re: Static shared data connection provider?"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 3 Apr 2004 22:45:49 -0500
Hi Jon,
Our solution is to detect the servername at runtime using code:
Dim strSERVER_NAME as string
strSERVER_NAME = Replace(Request.ServerVariables("SERVER_NAME"), ".", "_")
strDataBaseServer = ConfigurationSettings.AppSettings(strSERVER_NAME &
"_DataSource")
and store the appropriate value for its database in the web.config file.
<add key="localhost_DataSource" value="sqlserverdev" />
<add key="www_mysite_com_DataSource" value="sqlserverproduction" />
The application automatically finds its data wherever it is run.
Does this help?
Ken
Microsoft MVP [ASP.NET]
"Jon Davis" <jon@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:%2360E4HbGEHA.2612@TK2MSFTNGP09.phx.gbl...
>I like the drag-and-drop accessibility of dragging a table to a Web Forms
> designer and seeing a SqlDataAdapter automatically created for me.. being
> able to create a DataSet from that is fun and exciting, because now with
> this schema based data outline Visual Studio provides me with a typed
> class
> for managing data complete with Intellisense menus exposing my own field
> names as C# object properties ... cool ..
>
> Anyway, I have a problem. I am building this site for a client who hosts
> their own database, so my database is a test database. I have a different
> database connection string in my web.config file than my client's
> connection
> string in their web.config file. That file is the only file I want to
> differ
> between my development environment and the deployment environment.
>
> So now how do I get this cool functionality? I don't want to test and
> debug
> using live data. I'm stuck now because the connection string in the
> created
> connection object when dragging and dropping data adapters is hard-coded,
> and worse it is hard-coded into the specific web forms I'm dragging to.
>
> So I suppose I could change the connection string at runtime, but I would
> really rather not have to do this for every web form that uses it. Is
> there
> a way I can clean this up and consolidate my connection string while using
> this functionality?
>
> Jon
>
>
- Next message: Bill Borg: "Re: Compiled Code accessing New User Controls at runtime"
- Previous message: cgia: "How to deploy an application disabling the back button of the browser?"
- In reply to: Jon Davis: "Static shared data connection provider?"
- Next in thread: Jon Davis: "Re: Static shared data connection provider?"
- Reply: Jon Davis: "Re: Static shared data connection provider?"
- Messages sorted by: [ date ] [ thread ]