Visual Studio 2008 Connection Strings

Discussion in 'Programming' started by Bondizzo, Sep 4, 2009.

  1. #1
    Currently having a small problem, how do I set the connection string to be user specific in VS2008. I have a Solution that consists of 2 projects and I want both projects to use the same data source, at the moment its hard coded as an application setting so the system crashes when installed on another pc.
     
    Bondizzo, Sep 4, 2009 IP
  2. ziv

    ziv Peon

    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Connection string are stored in Web.Config file. Simply open that file, look for the connection string and change it.
     
    ziv, Sep 5, 2009 IP
  3. Bondizzo

    Bondizzo Well-Known Member

    Messages:
    150
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #3
    I'm looking at a windows application ? is there a way a user can set thier own connection string ?
     
    Bondizzo, Sep 5, 2009 IP
  4. jumboa7

    jumboa7 Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hello,

    You can save connectionstring in app.config file.

    Reference:
    hxxp://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/9a8c9f5a-092e-4c4a-87bb-9f35d8f55da1

    If you want to change connectionstring by user. You can use
    System.Configuration.ConfigurationSettings.AppSettings.Set(name, value);
    function

    Reference:
    hxxp://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/813c7b30-9d18-4484-86a0-630b54c897f3

    HTH
     
    jumboa7, Sep 7, 2009 IP
  5. vroom

    vroom Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    its a gud practice to save connectioon string in web.config file.
    but if u r doing windows application thn u kn go to project properties.and thn click on setting thr u kn save,,it will save it in app.config file.
     
    vroom, Sep 9, 2009 IP