• How to use multiple connection strings to databases in ASP.NET

    by  • June 28, 2013 • Microsoft ASP.NET • 1 Comment

    You can define connection string in your code just before you want to connect to a database. So whenever you want to connect to a database, you can define it connection string and establish your connection. But if you want to use same connection in different places then you have to define a connection string multiple times. The basic solution of this problem is to define your connection string in web.config file and use it anywhere in your code. You can define multiple connection strings for multiple connections to multiple databases. Let’s see how we can define multiple connection strings in web.config and how we can use it in our code file.

    First write your multiple connection strings in connectionStrings tag under configuration tag

    Now get multiple connections for multiple databases in your code




    Namecheap.com
    Avatar of GetCodeSnippet.com

    About

    GetCodeSnippet.com provides you high quality Microsoft .NET development related articles, tutorials and sample code for ASP.NET, C#, VB.NET, AJAX, WCF, WPF, Web Services, Windows Services, SQL Server and other technologies.

    One Response to How to use multiple connection strings to databases in ASP.NET

    1. Areeg
      March 15, 2014 at 9:02 am

      Thank you

    Leave a Reply