Wrox Programmer Forums
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 12th, 2004, 11:54 AM
Authorized User
Join Date: Mar 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Conditional Building and DSN

I need to be able to connect to a development SQL Server when building "Debug" and to a production server when building "Release". Currently I have two DSN settings in AppSettings of web.config file, but I need to remember to use the change the code to point to the correct one when building.

Does someone have an example of how to have the code recognize, through the Build Configuration, to either use a development DSN or a Production DSN so that I can write this in code once and forget about it?

Thanks in advance for your help.

Old March 12th, 2004, 12:48 PM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi djmarquette,

You can make use of the debugging constant DEBUG. You can write code that runs in Debug mode and some other code that runs in Release mode.

You could use that to define a connectionstring, like this:
string connectionstring = "";
    connectionstring = "Debug";
    connectionstring = "Release";
Instead of assigning the string directly, you could of course also retrieve it from a configuration file. Just define two connections with different names, and retrieve the appropriate one.



Imar Spaanjaars
Everyone is unique, except for me.
Old March 12th, 2004, 04:11 PM
Authorized User
Join Date: Mar 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks Imar. I was close, but your solution was exactly what I was looking for.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help please.......... DSN kumar1225 Java Databases 1 December 26th, 2007 09:02 AM
DSN umeshtheone SQL Server 2000 1 June 8th, 2007 04:18 AM
dsn umeshtheone SQL Server 2000 1 May 16th, 2007 04:54 AM
Application DSN and Session DSN ssampanthar Classic ASP Databases 0 January 6th, 2005 01:23 PM
coonrct using dsn vikaspalic SQL Server ASP 2 June 4th, 2003 02:40 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.