Avatar of jdana
jdanaFlag for United States of America

asked on 

.NET Windows App - How do I tweak the SQL Server connect string for the publish?

I've created my first Windows-based .NET apps that connects to SQL Server.  
- The development copy connects to my development SQL Server and works fine.  
- If I paste the contents of the project's bin\Release folder over to a production machine, modify the connect string found in MyApp.exe.config, it works fine.
- I want to do it right, however, by publishing the project.  How do I tell the publish process to use a different connect string?  Do I temporarily the connect string in app.config to configure it for the production server and then publish the project?  I doubt it.
- What is the accepted way of doing this?
.NET ProgrammingC#Visual Basic.NET

Avatar of undefined
Last Comment
jdana
SOLUTION
Avatar of Wouter Boevink
Wouter Boevink
Flag of Netherlands image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Molly Fagan
Molly Fagan
Flag of United States of America image

I don't use the "publish" process--I do the copy and paste what's in the bin\Release folder over.  What I do though for test and production database servers, I put both connection strings in my app.config and have a test value that I set to true or false and compile for the scenario (e.g. we have test applications that are used for training purposes, as well as testing the enhancements that I push out onto a server for end users to use) and in my code, when I open a database connection, I check to see what that value is set at and then use the corresponding connection string.
From your question:

"How do I tell the publish process to use a different connect string?"

SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of jdana
jdana
Flag of United States of America image

ASKER

Awesome!
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo