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

8/22/2022 - Mon
SOLUTION
Wouter Boevink

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Molly Fagan

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.
Wouter Boevink

From your question:

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

SOLUTION
Nasir Razzaq

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
jdana

Awesome!
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy