Results 1 to 3 of 3

Thread: [RESOLVED] VB.NET Multiple Database Connection

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2010
    Posts
    24

    Resolved [RESOLVED] VB.NET Multiple Database Connection

    is there a function that will allow coders to connect to multiple database? by just changing the connection string and not the variable declaration ...

    example:

    connecting to access is something like this
    Code:
    Dim Con As New System.Data.OleDb.OleDbConnection(ConString)
    for sql is something like this
    Code:
    Dim Con As New System.Data.SqlClient.SqlConnection(ConString)
    is it possible? acctually in vb 6.0 it is possible .... plz help me ... im new in .net ....

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: VB.NET Multiple Database Connection

    An OleDbConnection is not just for connecting to Access. It is for connecting to any OLE DB data source, i.e. any database or other data source for which there exists an OLE DB provider. You'll notice that, in your connection string for Access, the Provider is specified as either Microsoft Jet or Microsoft ACE. Both of those can also be used to connect to Excel, text files and various others too. There is also an OLE DB provider for SQL Server, as there is for just about every data source you would likely want to connect to.

    If you want to be able to connect to multiple data sources then OleDb is probably your best bet. You might also use Odbc, which uses an ODBC driver in basically the same was as OleDb uses an OLE DB provider. In order of preference, you should generally choose to use a data-source-specific provider, then OleDb, then Odbc.

    If you visit www.connectionstrings.com then you can see a SQL Server connection string for both OleDb and Odbc. The same goes for most other data sources listed there.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2010
    Posts
    24

    Re: VB.NET Multiple Database Connection

    wow ... what a quick reply ... tnx for the help ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width