|
-
Dec 15th, 2011, 10:18 PM
#1
Thread Starter
Junior Member
[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 ....
-
Dec 15th, 2011, 10:31 PM
#2
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.
-
Dec 15th, 2011, 10:53 PM
#3
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|