Using Multiple Databases with a single web application in asp.NET

Last post 01-31-2008 7:34 AM by nr2ae. 2 replies.

Sort Posts:

  • Using Multiple Databases with a single web application in asp.NET

    01-31-2008, 7:11 AM
    • Loading...
    • thangapandi
    • Joined on 01-31-2008, 11:18 AM
    • Posts 1

    Do we can use multiple Databases (say SQL Server ,Oracle and SAP Server) with a single asp.NET application (data architecture is the same in every data bases)? If so, How do we achieve the same?

     

    Thanks,'

    Thangapandi M

  • Re: Using Multiple Databases with a single web application in asp.NET

    01-31-2008, 7:29 AM
    Answer
    • Loading...
    • jimmy q
    • Joined on 11-02-2006, 9:01 AM
    • Australia
    • Posts 2,489
    • Moderator

    thangapandi:
    Do we can use multiple Databases (say SQL Server ,Oracle and SAP Server) with a single asp.NET application (data architecture is the same in every data bases)? If so, How do we achieve the same?
     

    You certainly can use multiple different databases in a single web application, e.g. both oracle and sql

    The best way to do this is to make things generic by using interfaces/abstract classes, so instead of using provider specific connection and command objects from SQL and Oracle you should use interfaces like the IDBConnection and IDBCommand.

    Alternatively if you are using .NET 2.0 look into the DBProviderFactory class in the System.Data.Common namespace. It is a factory class that creates concrete classes using interfaces so you can tell it what type of provider you want and it would not affect how you use it.

     

  • Re: Using Multiple Databases with a single web application in asp.NET

    01-31-2008, 7:34 AM
    Answer
    • Loading...
    • nr2ae
    • Joined on 03-04-2006, 1:55 AM
    • Posts 72

    Is the question "Can we use multiple databases in a single ASP.NET application" ?

    For most cases, you can

    .net Framework has classes and APIs ready for both SQL Server and Oracle (System.Data.SqlClient and Sql.Data.OracleClient

    For MySql there's a libray available for download at MySql web site.

    But for others you might need to use OLEDB / ODBC.

     

    Most of the database-related classes inherit from the base classes in System.Data.Common

    For example, System.Data.SqlClient.SQLConnection and System.Data.OracleClient.OracleConnection inherit from System.Data.Common.DbConnection

     

    Put it simply, you should be able to use the same technique with different data sources.

Page 1 of 1 (3 items)
Microsoft Communities
Page view counter