none
How do I configure a new connection using the default connection string located in the connection settings RRS feed

  • Question

  •  

    I would like to be able to use a single place to set the default server instance and database for the connection settings in my c# app.  I have one that the ide created for me, is there a way to create a new instance using that same infromation so that i could distribute the app that I'm building to a variety of people without having to specify in my coding where the database is stored?
    Friday, May 23, 2008 9:57 PM

Answers

  • You should store your connection string in application configuration file (.config file). In this case you can compile application without worrying about connection string, because .config file is plain text and could be changed any time to adjust for specific customer. Next link shows details about how to use .config file to store and use connection strings

     

    http://msdn.microsoft.com/en-us/library/ms254494(VS.80).aspx

    Saturday, May 24, 2008 1:54 AM
    Moderator
  • You can also create an Alias in the SQL Server Configuration utility. The ConnectionString would (or the UI code generators) can point to the alias which can be changed on the target system at any time by the Admin. The Alias points to the specific SQL Server instance to reference at runtime.

     

    Saturday, May 24, 2008 7:13 PM
    Moderator

All replies

  • You should store your connection string in application configuration file (.config file). In this case you can compile application without worrying about connection string, because .config file is plain text and could be changed any time to adjust for specific customer. Next link shows details about how to use .config file to store and use connection strings

     

    http://msdn.microsoft.com/en-us/library/ms254494(VS.80).aspx

    Saturday, May 24, 2008 1:54 AM
    Moderator
  • You can also create an Alias in the SQL Server Configuration utility. The ConnectionString would (or the UI code generators) can point to the alias which can be changed on the target system at any time by the Admin. The Alias points to the specific SQL Server instance to reference at runtime.

     

    Saturday, May 24, 2008 7:13 PM
    Moderator