Need to access the Project - Settings in VS 2008?

Posted on 2009-02-12
Last Modified: 2013-11-26
I need to get access to the Project - Settings in Visual Studio 2008 via Code, I found out how to do it in VS 2005 - GetDefaults() [In this video by Pat Tormey demonstrates how to implement settings and place resources in Visual Studio.], but VS 2008 does not have GetDefaults(). I couild not find anything for Visual Studio 2008.

So what do I use in my code and where do I place it?
Reason and Goal: I  need to be able to change the Connection string for SQL in my entire project from my site to the customers site.
Question by:ITCSAdmin
    LVL 12

    Expert Comment

    hi, It seems for a webapplication these settings(connection) should be in webconfig file that can be edited using configurationManager from System.Configuration namespace.

    and in Window forms application it should either in app.config or Application settings.

    appconfig can do edited using same way configurationManager and for applicationSettings you may access via My.******* its propertiese.

    not sure, if was that same that are trying to ask?


    Author Comment

    I think I have part of the solution, but I have not find out any additional information to help me complete the following:

    "PLMConnectionString" is the ConnectionString that I am using, but what I need is to know how to change the String after Deployment to match the customers information.
    • My current String is: "Data Source=ITCS-SQL-01; Initial Catalog=PLM; User ID=PLMAdmin; Password=*********"
    • Customers Should be: "Data Source=RPL-ADS01;Initial Catalog=PLM;User ID=PLMAdmin;Password=*********"
    Also where in my project do I need to place this code to make it global?
    LVL 1

    Expert Comment

    Hi ITCSAdmin,

    I tend not to use the default settings file for applications since this gets baked in to the dll once the application is compiled and the only way to change it is to recompile and redeploy the solution with the new default settings.

    The better and easier way to have configurable settings for an application on a global level is to have an
     secion in your web.config (web application) or app.config (windows application)

    so here are the steps
    1. Add an app.config or web.config (if you don't already have one) to the startup application in your solution
    2. Add an appsettings node as follows within the   tags in the config file




    3. Import System.Configuration in the .vb file where you need to access the configuration
       IMPORTS System.Configuration

    4. In place of ConnectionString= My.MySettings.Default.PLMConnectionString.
    use  ConnectionString= ConfigurationManager.AppSettings["ConnectionString"]

    5. Now you can compile and deploy your application to your customer and all you have to do is change the value of the connectionstring setting from



    Author Comment

    I was OK up to step 2, but step 3 and beyond I am lost. Would you please turn the lighth on for me. Remember I am developing in VS 2008/VB9, am using SQL 2005 and I am a beginner. This is my first project, and it is a large and complex project as I now see it and have been told. Though I have a customer that needs this application and yet I want to "Do It Right!"

    Attached is the APP.Config code for this Application:
    <?xml version="1.0" encoding="utf-8" ?>
        <add key="ConnectionString" value="Data Source=ITCS-SQL-01; Initial Catalog=PLM; User ID=PLMAdmin; Password=*********"/>
            <add name="Lighthouse.My.MySettings.PLMConnectionStringDev" connectionString="Data Source=ITCS-SQL-01;Initial Catalog=PLM;User ID=PLMAdmin;Password=PLMA@dm1n"
                providerName="System.Data.SqlClient" />
            <add name="Lighthouse.My.MySettings.PLMConnectionStringDeploy" connectionString="Data Source=RPL-ADS01;Initial Catalog=PLM;User ID=PLMAdmin;Password=PLMA@dm1n" />
                <!-- This section defines the logging configuration for My.Application.Log -->
                <source name="DefaultSource" switchName="DefaultSwitch">
                        <add name="FileLog"/>
                        <!-- Uncomment the below section to write to the Application Event Log -->
                        <add name="EventLog"/>
                <add name="DefaultSwitch" value="Information" />
                <add name="FileLog"
                     type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
                <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
                <add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="Lighthouse"/> 

    Open in new window


    Author Comment

    needo_jee & vkarumbaiah

    I found part of my question and would like to update you on where I got the information. There is a big difference between Visual Studio 2005 and 2008. This is one of them. To deploy in VS 2005, you would just from you toolbar, change it from Debug to Deploy, but in VS 2008 you now have to due the following:

    Watch the following Video

    This is the first part, Now the second is I need to be able to switch from SQL 2005 Standard (Development) to either SQL 2005 Express or SQL 2008 Express (Deployment) ConnectionString or do I have to change my project to ONLY use either SQL Standard or SQL Express for the entire project.

    Also, this solution needs to work across the entire project, multiple Tables, multiple Forms, Multiple DataSets, etc..

    Have any suggestions or thoughts?

    REMEMBER I am using Visual Studio 2008 Professional!!!

    Accepted Solution

    needo_jee & vkarumbaiah

    I have found part two by watching the following video on "Datasets and Connection Strings" by Pat Tormey. Check it out, it really works.
    LVL 1

    Expert Comment

    Yep that works too! Thanks for posting the links to the videos! they're great.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now