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.
Next: Code >>
More MS SQL Server Articles
More By Jayaram Krishnaswamy