Database connection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Kirk

    Database connection

    Hi

    I am writing a windows service which needs to access a database (which will
    be running on a different machine). I don't know what the database is (maybe
    oracle, maybe sql server - it is something that needs to be
    configured/installed at deployment time).

    How do I make a "connection " to a database? Is there a generic "IConnectio n"
    interface and various "factories" for different databases? For example
    IConnection conn = OracleDatabase. GetConnection() ;
    IConnection conn = SqlServer.GetCo nnection();

    Any help/advice appreciated.

    Thanks,
    Peter


  • Morten Wennevik

    #2
    Re: Database connection

    AFAIK you can use OleDbConnection for any database. All that needs to change is the connection string.

    All connection strings in one place. Find the syntax for your database connection using ADO.NET, ADO, ODBC, OLEDB, C#, VB, VB.NET, ASP.NET and more.



    On Tue, 31 May 2005 10:01:15 +0200, Peter Kirk <pk@alpha-solutions.dk> wrote:
    [color=blue]
    > Hi
    >
    > I am writing a windows service which needs to access a database (which will
    > be running on a different machine). I don't know what the database is (maybe
    > oracle, maybe sql server - it is something that needs to be
    > configured/installed at deployment time).
    >
    > How do I make a "connection " to a database? Is there a generic "IConnectio n"
    > interface and various "factories" for different databases? For example
    > IConnection conn = OracleDatabase. GetConnection() ;
    > IConnection conn = SqlServer.GetCo nnection();
    >
    > Any help/advice appreciated.
    >
    > Thanks,
    > Peter
    >
    >
    >[/color]



    --
    Happy coding!
    Morten Wennevik [C# MVP]

    Comment

    Working...