MS SQL Server
  Home arrow MS SQL Server arrow Page 2 - SQL Connection: Connecting to Multiple Dat...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MS SQL SERVER

SQL Connection: Connecting to Multiple Databases
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 21
    2005-08-22

    Table of Contents:
  • SQL Connection: Connecting to Multiple Databases
  • Saving multiple connections in Web.config
  • Code
  • Connection Using Dynamic Properties of the SQLConnection Control

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    SQL Connection: Connecting to Multiple Databases - Saving multiple connections in Web.config


    (Page 2 of 4 )

    It is possible to connect to any of a plurality of SQL 2000 servers by storing the connection string information in a web.config file. For a local SQL server you can connect to any of the databases, or for databases on different accessible SQL 2000 servers.

    The VB.NET studio available to this tutorial restricts connection to databases on the local machine only. The two servers chosen for this tutorial are a SQL 2000 server (aka localhost), and a Desktop MSDE called XPHTEK/TEST. The servers and the databases accessed are as shown in the next two pictures.

     

     

    Both servers are accessed by the ASP.NET and therefore, the databases that are accessed should have the proper login information as shown in these pictures.

     

    If these login permissions are not there, they should be configured before they can be accessed via web application. With these initial tasks taken care of, the web.config file for these servers are configured as shown below:

    <appSettings>
    <add key="books"
    value="Server=localhost;integrated security=SSPI;database=Biblio"/>
    <add key="info"
    value="Server=XPHTEKTEST;integrated security=SSPI;database=RCC"/>
    </appSettings>
    
    Procedure to connect to multiple servers

    A web application is created and a web form is added. The connection to the databases is established in the click event of button as shown in the user interface of this application. The web.config file of this application has the aforementioned appSettings.

    More MS SQL Server Articles
    More By Jayaram Krishnaswamy


       · This tutorial is a continuation of an article you may find at the following...
       · Once you have your user-chosen connection string, how can you keep it for further...
       · This article is just about keeping multiple connections strings in one place, namely...
     

    MS SQL SERVER ARTICLES

    - Completing the Introduction to Transact-SQL
    - A Brief Introduction to Transact-SQL
    - Lookups and Blocking Bad Data
    - Field Validation Rules for Blocking Bad Data
    - Using Masks to Block Bad Data
    - Blocking Bad Data
    - Using @@ROWCOUNT and TABLE Variables for Dat...
    - How to Use Variables, IF and CASE in Databas...
    - Creating Important Aspects of Notification S...
    - Working wth Variables in Database Interactio...
    - Delving Deeper into Notification Services
    - Notification Services
    - Building a Multi-table Report with SQL 2005 ...
    - A Secure Way of Building Connection Strings
    - Transferring a Database Using the SSIS Desig...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT