ADO Connection String Samples
ADO Connection String Samples
ADO Connection String Samples
1 of 23
http://www.codemaker.co.uk/it/tips/ado_conn.htm
Table of Contents
.NET Data Provider Connections
MySQL .NET Native Provider
ODBC .NET Data Provider
OLE DB .NET Data Provider
Oracle .NET Data Provider
SQL Server .NET Data Provider
ODBC DSN Connections
DSN
File DSN
ODBC DSN-Less Connections
ODBC Driver for Access
ODBC Driver for AS/400
ODBC Driver for dBASE
ODBC Driver for Excel
ODBC Driver for Informix
ODBC Driver for Interbase (from Easysoft)
ODBC Driver for Interbase (from InterSolv)
ODBC Driver for Lotus Notes
ODBC Driver for MySQL
ODBC Driver for Oracle (from Microsoft)
ODBC Driver for Oracle (from Oracle)
ODBC Driver for Paradox
ODBC Driver for SQL Server
ODBC Driver for Sybase
ODBC Driver for Sybase SQL Anywhere
ODBC Driver for Text
ODBC Driver for Teradata
ODBC Driver for Visual FoxPro
OLE DB Data Link Connections
Data Link File (UDL)
OLE DB Data Provider Connections
OLE DB Provider for Active Directory Service
OLE DB Provider for Advantage
OLE DB Provider for AS/400 (from IBM)
OLE DB Provider for AS/400 and VSAM (from Microsoft)
OLE DB Provider for Commerce Server
OLE DB Provider for DB2
OLE DB Provider for DTS Packages
OLE DB Provider for Exchange
OLE DB Provider for Excel
OLD DB Provider for Internet Publishing
OLE DB Provider for Index Server
OLE DB Provider for Microsoft Jet
OLE DB Provider for Microsoft Project
OLE DB Provider for MySQL
OLE DB Provider for ODBC Databases
OLE DB Provider for OLAP Services
OLE DB Provider for Oracle (from Microsoft)
OLE DB Provider for Oracle (from Oracle)
OLE DB Provider for Pervasive
19/06/2012 18:04
2 of 23
OLE
OLE
OLE
OLE
OLE
OLE
OLE
OLE
OLE
DB
DB
DB
DB
DB
DB
DB
DB
DB
http://www.codemaker.co.uk/it/tips/ado_conn.htm
Provider
Provider
Provider
Provider
Provider
Provider
Provider
Provider
Provider
for
for
for
for
for
for
for
for
for
Simple Provider
SQLBase
SQL Server
SQL Server via SQLXMLOLEDB
Sybase Adaptive Server Anywhere
Sybase Adaptive Server Enterprise
Text Files
UniData and UniVerse
Visual FoxPro
19/06/2012 18:04
3 of 23
http://www.codemaker.co.uk/it/tips/ado_conn.htm
"Dbq=c:\somepath\mydb.mdb;" & _
"SystemDB=c:\somepath\mydb.mdw;", _
"myUsername", "myPassword"
19/06/2012 18:04
http://www.codemaker.co.uk/it/tips/ado_conn.htm
(Q238431).
For more information, see: dBASE Driver Programming Considerations
To view Microsoft KB articles related to Microsoft dBASE Driver, click here
4 of 23
19/06/2012 18:04
5 of 23
http://www.codemaker.co.uk/it/tips/ado_conn.htm
Connection keywords
19/06/2012 18:04
6 of 23
http://www.codemaker.co.uk/it/tips/ado_conn.htm
19/06/2012 18:04
7 of 23
http://www.codemaker.co.uk/it/tips/ado_conn.htm
19/06/2012 18:04
8 of 23
http://www.codemaker.co.uk/it/tips/ado_conn.htm
For more information, see: HOWTO: Use Data Link Files with ADO
Note: Windows 2000 no longer contains the "New | Microsoft Data Link" menu anymore. You can add
the Data Link menu back in the menu list by running the "C:\Program Files\Common Files\System\Ole
DB\newudl.reg" reg file, then right-click on the desktop and select "New | Microsoft Data
Link" menu.
Or you can also create a Data Link file by creating a text file and change it's file extension to ".udl",
then double-click the file.
To view Microsoft KB articles related to Data Link File, click here
19/06/2012 18:04
9 of 23
http://www.codemaker.co.uk/it/tips/ado_conn.htm
19/06/2012 18:04
10 of 23
http://www.codemaker.co.uk/it/tips/ado_conn.htm
oConn.Open _
"URL=mscop://InProcConnect/Server=myServerName:" & _
"Database=myDBname:Catalog=Profile Definitions:" & _
"User=myUsername:Password=myPassword"
For more information, see: OLE DB Provider for Commerce Server, DataWarehouse, and Profiling
System
To view Microsoft KB articles related to OLE DB Provider for Commerce Server, click here
19/06/2012 18:04
11 of 23
http://www.codemaker.co.uk/it/tips/ado_conn.htm
For more information, see: Microsoft OLE DB Provider for Microsoft Indexing Service
To view Microsoft KB articles related to OLE DB Provider for Index Server, click here
19/06/2012 18:04
12 of 23
http://www.codemaker.co.uk/it/tips/ado_conn.htm
%>
This assumes the MDB is in the same directory where the ASP page is running. Also make sure this
directory has Write permissions for the user account.
You can also open an Excel Spreadsheet using the JET OLE DB Provider
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\somepath\mySpreadsheet.xls;" & _
"Extended Properties=""Excel 8.0;HDR=Yes"""
Where "HDR=Yes" means that there is a header row in the cell range
(or named range), so the provider will not include the first row of the
selection into the recordset. If "HDR=No", then the provider will include
the first row of the cell range (or named ranged) into the recordset.
For more information, see: Q278973
You can also open a Text file using the JET OLE DB Provider
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\somepath\;" & _
"Extended Properties=""text;HDR=Yes;FMT=Delimited"""
'Then open a recordset based on a select on the actual file
oRs.Open "Select * From MyTextFile.txt", oConn, _
adOpenStatic, adLockReadOnly, adCmdText
For more information, see: Q262537
19/06/2012 18:04
13 of 23
http://www.codemaker.co.uk/it/tips/ado_conn.htm
19/06/2012 18:04
14 of 23
http://www.codemaker.co.uk/it/tips/ado_conn.htm
19/06/2012 18:04
http://www.codemaker.co.uk/it/tips/ado_conn.htm
15 of 23
19/06/2012 18:04
16 of 23
http://www.codemaker.co.uk/it/tips/ado_conn.htm
19/06/2012 18:04
http://www.codemaker.co.uk/it/tips/ado_conn.htm
Note: The Visual FoxPro OLE DB Provider is NOT installed by MDAC 2.x. You must install Visual FoxPro
7.0 in order to get it's OLE DB Provider.
[sql MySQLTag]
Sql = "Select * From Authors Where State = '?'"
For more information about the RDS Default Handler, see: Q243245, Q230680, and RDS Customization
Handler Microsoft articles
To view Microsoft KB articles related to RDS, click here
17 of 23
19/06/2012 18:04
18 of 23
http://www.codemaker.co.uk/it/tips/ado_conn.htm
End With
19/06/2012 18:04
http://www.codemaker.co.uk/it/tips/ado_conn.htm
and Q240838
19 of 23
19/06/2012 18:04
20 of 23
http://www.codemaker.co.uk/it/tips/ado_conn.htm
Using VB.NET:
Imports System.Data.SqlClient
...
Dim oSQLConn As SqlConnection = New SqlConnection()
oSQLConn.ConnectionString = "Data Source=(local);" & _
"Initial Catalog=mySQLServerDBName;" & _
"Integrated Security=yes"
oSQLConn.Open()
For more information, see: System.Data.SQL Namespace, Q308656, and .NET Data Providers
Note: Microsoft SQLXML Managed Classes exposes the functionality of SQLXML inside the Microsoft
.NET Framework.
To view Microsoft KB articles related to SQLClient, click here
19/06/2012 18:04
21 of 23
http://www.codemaker.co.uk/it/tips/ado_conn.htm
oOleDbConnection.Open()
19/06/2012 18:04
22 of 23
http://www.codemaker.co.uk/it/tips/ado_conn.htm
Using VB.NET:
Imports System.Data.OracleClient
Dim oOracleConn As OracleConnection = New OracleConnection()
19/06/2012 18:04
http://www.codemaker.co.uk/it/tips/ado_conn.htm
Using VB.NET
Imports EID.MySqlClient
Dim oMySqlConn As MySqlConnection = New MySqlConnection()
oMySqlConn.ConnectionString = "Data Source=localhost;" & _
"Database=mySQLDatabase;" & _
"User ID=myUsername;" & _
"Password=myPassword;" & _
"Command Logging=false"
oMySqlConn.Open()
23 of 23
19/06/2012 18:04