net windows app.config change setting for sqlconnection in build

Posted on 2009-07-06
Medium Priority
Last Modified: 2013-12-17

Have windows application in c# (.net) and using sql express - when developing have sqlconnection string in settings to local but when create exe for user/distribution I want to change the connection string in the app.config file

I thought it would fit in build events (pre or post) but cannot find code snippet to change values to user setting and after buil;d bakcto development

any ideas on code syntax or is there a better way to do it

Question by:stephenwilde
  • 2
LVL 71

Accepted Solution

Éric Moreau earned 750 total points
ID: 24783991
LVL 13

Assisted Solution

by:George Hirst
George Hirst earned 750 total points
ID: 24783995

Author Comment

ID: 24784077

But in app config file using an application variable not full connection string for which is no option in my visual studio winddows application to do - and the syntax in pre/post build seems dos like dont wont 2 app config files to maintain as lots of other items/settings in them so would need syntax to change only a value


Author Closing Comment

ID: 31600100

Featured Post

Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Native ability to set a user account password via AD GPO was removed because the passwords can be easily decrypted by any authenticated user in the domain. Microsoft recommends LAPS as a replacement and I have written an article that does something …
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question