ADO connection database string Daquan
This Page Contains Sample Ado Connection Strings for ODBC DSN / DSN-Less,
OLE DB Providers, Remote Data Services (RDS), MS Remote, MS DataShape.
Also Included Are ADO.NET Connection Strings for Each .NET Managed Provider
SqlClient, OLEDB, And ODBC.
Thase Sample Connection Strings Are Compiled
By Carl Prothman, A Microsoft Visual Basic MVP
Enjoy!
Table of contents
ODBC DSN CONNECTIONS DSN
FILE DSN
ODBC DSN-LESS Connections ODBC Driver for AS / 400
ODBC DRIVER FOR Access
ODBC Driver for DBASE
ODBC Driver for Excel
ODBC DRIVER for Mysql
ODBC Driver for 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 AS / 400
OLE DB Provider for Active Directory Service
OLE DB Provider for DB2
Old DB Provider for Internet Publishing, INTERNET PUBLISHING
OLE DB Provider for Index Server
OLE DB Provider for Microsoft Jet
OLE DB Provider for ODBC Databases
OLE DB Provider for Oracle (from Microsoft)
OLE DB Provider for Oracle (from oracle)
OLE DB Provider for Simple Provider
OLE DB Provider for SQL Server
Remote Data Service (RDS) Connections RDS Data Control - Connect Property
RDS Data Control - URL Property
ADO URL Connections Ado Recordset
MS Remote Provider Connections MS Remote - Access (Jet)
MS Remote - SQL Server
Data Shape Provider Connections MS Datashape - SQL Server
.NET Managed Provider Connections SQL Client .NET Managed Provider (System.Data.sqlclient)
OLE DB .NET Managed Provider (System.Data.Oledb)
ODBC .NET Managed Provider (System.Data.odbc)
ODBC DSN Connectionsusing An ODBC DSN (Data Source Name) is A Two Step Process.
1) You Must First Create The DSN Via The "ODBC Data Source Administrator" program "Program
Found In your Computer's Control Panel (or Administrative Tools Menu In Windows 2000).
Make Sure To create a System DSN (not a user dsn) WHEN USING ASP.
Note: you can also create the dsn vib code.
2) THEN USE The FOLLOWING Connection String - with your own dsn name of course. ;-)
ODBC - DSN
Oconn.open "DSN = Advworks;" & _
"Uid = admin;" & _
PWD =;
You can also create and use a file dsn. The Use the Following ADO Connection String:
ODBC - File DSN
Oconn.open "filedsn = c: /somepath/mydb.dsn;" & _
"Uid = admin;" & _
"Pwd =;"
For more information, see: About ODBC Data Sources and
How to use file dsns and dsn-less connections
NOTE: The Problem with DSN Is That Users CAN (AND WILL) MODIFY THEM (OR DELETE BY MISTAKE),
Then Your Program Won't work so well ... so it's better to use a dsn-length or ole DB Provider
Connection String With a trusted connection if Possible!
ODBC DSN-Less Connections
ODBC Driver for AS / 400
Oconn.open "Driver = {Client Access ODBC Driver (32-bit)};" & _
"System = myas400;" & _
"UID = myusername;" & _
"Pwd = mypassword;"
For more information, see: a fast path to as / 400 client / server
ODBC DRIVER FOR Access
For Standard Security:
Oconn.open "Driver = {Microsoft Access Driver (* .mdb)};" & _
"DBQ = C: /SOMEPath/mydb.mdb;" & _
"Uid = admin;" & _
"Pwd =;"
IF you are using a workgroup (System Database):
Oconn.open "driver = {Microsoft Access Driver (* .mdb)};" & _ "DBQ = C: /SOMEPATH/Mydb.mdb;" & _
"Systemdb = c: /somepath/mydb.mdw;", _
"admin", ""
IF MDB IS LOCATED ON A NetWork Share:
Oconn.open "Driver = {Microsoft Access Driver (* .mdb)};" & _
"DBQ = // myserver / myshare / mypath / mydb.mdb;"
For more information, see: Microsoft Access Driver Programming Considances
ODBC Driver for DBASE
Oconn.open "driver = {Microsoft DBase Driver (* .dbf)};" & _
Driverid = 277; "& _
"DBQ = C: / SomePath;"
Note: Specify The FileName In The Sql Statement. For example:
Ors.open "Select * from user.dbf", Oconn,, AdcmdText
Note: MDAC 2.1 (or greater) Requires The Borland Database Engine (BDE) To Update DBase DBF Files. (Q238431).
For More Information, See: DBase Driver Programming Considances
ODBC Driver for Excel
Oconn.open "driver = {Microsoft Excel Driver (* .xls)};" & _
Driverid = 790; "& _
"DBQ = C: /SOMEPath/Myspreadsheet.xls;" & _
"Defaultdir = c: / somepath;"
For more information, see: Microsoft Excel Driver Programming Considances
ODBC Driver for MySQL (VIA Myodb)
To Connect to a local database
Oconn.open "driver = {mysql};" & _
"Server = myservername;" & _
Option = 16834; "& _
"Database = mydb;"
To Connect to A Remote Database
Oconn.open "driver = {mysql};" & _
"Server = db1.database.com;" & _
"Port = 3306;" & _
"OPTION = 131072;" & _
"STMT =;" & _
"Database = MyDB;" & _
"Uid = myusername;" & _ "pwd = mypassword;"
For more information, see: programs known to work with myodbc
ODBC Driver for Oracle
For The Current Oracle ODBC Driver from Microsoft:
Oconn.open "driver = {microsoft odbc for oracle};" & _
"Server = oracleserver.world;" & _
"UID = myusername;" & _
"Pwd = mypassword;"
For The Older Oracle ODBC Driver from Microsoft:
Oconn.open "driver = {Microsoft ODBC Driver for Oracle};" & _
"ConnectString = OraclesRver.world;" & _
"UID = myusername;" & _
"Pwd = mypassword;"
For More Information, See: Connection String Format and Attributes
ODBC DRIVER for PARADOX
Oconn.open "driver = {Microsoft Paradox Driver (* .db)};" & _
Driverid = 538; "& _
"Fil = Paradox 5.x;" & _
"Defaultdir = c: / dbpath /;" & _
"DBQ = C: / dbpath /;" & _
"Collatingsequence = ascii;"
Note: MDAC 2.1 (or greater) Requires The Borland Database Engine (BDE) TO Update Paradox Isam FDBF Files. (Q230126).
For More Information, See: Paradox Driver Programming Considances
ODBC DRIVER for SQL Server
For Standard Security:
Oconn.open "driver = {SQL Server};" & _
"Server = myservername;" & _
"Database = MyDatabaseName;" & _
"UID = myusername;" & _
"Pwd = mypassword;"
For Trusted Connection Security:
Oconn.open "driver = {SQL Server};" & _
"Server = myservername;" & _
"Database = MyDatabaseName;" & _
"UID =;" & _
"Pwd =;"
'OR
Oconn.open "Driver = {SQL Server};" & _ "Server = myservername;" & _
"Database = MyDatabaseName;" & _
Trusted_Connection = YES; "
To Prompt User for UserName and Password
Oconn.properties ("prompt") = adpromptalways
Oconn.open "driver = {SQL Server};" & _
"Server = myservername;" & _
"Database = MyDatabaseName;"
For more information, see: SqldriverConnect (ODBC)
ODBC DRIVER for Sybase
IF using the Sybase System 11 ODBC Driver:
Oconn.open "driver = {Sybase System 11};" & _
"SRVR = MyServerName;" & _
"UID = myusername;" & _
"Pwd = mypassword;"
IF using the intersolv 3.10 Sybase ODBC DRIVER:
Oconn.open "Driver = {INTERSOLV 3.10 32-bit Sybase};" & _
"SRVR = MyServerName;" & _
"UID = myusername;" & _
"Pwd = mypassword;"
For more information, see: Sybase System 10 ODBC Driver Reference Guide
ODBC Driver for Sybase SQL Anywhere
Oconn.open "ODBC; Driver = Sybase SQL Anywhere 5.0;" & _
"Defaultdir = c: / dbpath /;" & _
"Dbf = c: /sqlany50/mydb.db;" & _
"UID = myusername;" & _
"Pwd = mypassword;"
"DSN =" "" ";"
NOTE: INCLUDING TAG WITH A NULL STRING IS ABSOLUTELY CRITI ELSE You get the dreamed -7778 error.
For more information, see: Sybase SQL Anywhere User Guide
ODBC Driver for Teradata
Oconn.open "provider = teradata;" & _
"Dbcname = mydbcname;" & _
"Database = MyDatabaseName;" & _
"UID = myusername;" & _
"Pwd = mypassword;"
For More Information, See Teradata ODBC Driverodbc Driver for Text
Oconn.open "driver = {Microsoft text driver (* .txt; * .csv)};" & _
"DBQ = C: / SomePath /;" & _
"Extensions = ASC, CSV, Tab, TXT;" & _
"Persist security info = false"
Note: Specify The FileName In The Sql Statement. For example:
Ors.open "SELECT * from Customer.csv", _
Oconn, AdopenStatic, AdlockReadonly, AdcmdText
For More Information, See: Text File Driver Programming Considances
ODBC Driver for Visual FoxPro
With a database container:
Oconn.open "driver = {Microsoft Visual FoxPro Driver};" & _
"SourceType = DBC;" & _
"SOURCEDB = C: /SOMEPATH/Mysourcecedb.dbc;" & _
"EXclusive = NO;"
WITHOUT A DATABASE Container (Free Table Directory):
Oconn.open "driver = {Microsoft Visual FoxPro Driver};" & _
SourceType = DBF; "& _
"SOURCEDB = C: / somepath / mysourcedbfolder;" & _
"EXclusive = NO;"
For more information, see: Visual FoxPro Odbc Driver and Q165492
OLE DB DATA LINK CONNECTIONS
Data Link File (UDL)
For Absolute Path:
Oconn.open "file name = c: /somepath/mydatabaseename.ud1;"
For Relative Path:
Oconn.open "file name = myDatabaseName.UDL;"
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 IN 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 to ".udl", the double-click the file.
OLE DB Provider Connections
OLE DB Provider for AS / 400
Oconn.open "provider = IBMDA400;" & _
"Data Source = MyAS400;"
"User ID = myusername;" & _
"Password = mypassword;"
For more information, see: a fast path to as / 400 client / server
OLE DB Provider for Active Directory Service
Oconn.open "provider = adsdsoobject;" & _
"User ID = myusername;" & _
"Password = mypassword;"
For more information, See: Microsoft Ole DB Provider for Microsoft Active Directory Service
OLE DB Provider for DB2
Oconn.open = "provider = db2oledb;" &
"NetWork Transport Library = TCPIP;" &
"NetWork address = myserver;" & _
Package Collection = Mypackage; &
Host CCSID = 1142
Initial Catalog = MyDB; &
"User ID = myusername;" & _
"Password = mypassword;"
For More Information, See: OLE DB Provider for DB2
AND INF: Configuring Data Sources for the Microsoft Ole DB Provider for DB2
OLE DB Provider for Index Server
Oconn.open "provider = msidxs;" & _
Data Source = MyCatalog; "
For More Information, See: Microsoft Ole DB Provider for Microsoft Indexing Service
OLE DB Provider for Internet Publishing
Oconn.open "provider = msdaipp.dso;" & _
"Data Source = http: // mywebsite / mydir;" & _
"User ID = myusername;" & _
"Password = mypassword;"
For more information, see: Microsoft Ole DB Provider for Internet Publishing and Q245359ole DB Provider for Microsoft Jet
For Standard Security:
Oconn.open "provider = microsoft.jet.Oledb.4.0;" & _
"Data Source = C: /SOMEPATH/Mydb.mdb;" & _
"User ID = admin;" & _
"Password =;"
IF using a workgroup (System Database):
Oconn.open "provider = microsoft.jet.Oledb.4.0;" & _
"Data Source = C: /SOMEPATH/Mydb.mdb;" & _
"Jet OLEDB: System Database = mysystem.mdw;", _
"admin", ""
Note, Remember to Convert Both The MDB and The MDW to The 4.0 Database Format When Using The 4.0 OLE DB Provider.
IF MDB HAS A DATABASE PASSWORD:
Oconn.open "provider = microsoft.jet.Oledb.4.0;" & _
"Data Source = C: /SOMEPATH/Mydb.mdb;" & _
"Jet OLEDB: Database Password = mydbpassword;", _
"admin", ""
IF MDB IS LOCATED ON A NetWork Share:
Oconn.open "provider = microsoft.jet.Oledb.4.0;" & _
"Data Source = // myserver / myshare / mypath / mydb.mdb;
IF Want To Open Up The Access Database Exclusive:
Oconn.mode = admodeshareExClusive
Oconn.open "provider = microsoft.jet.Oledb.4.0;" & _
"Data Source = C: /SOMEPATH/Mydb.mdb;" & _
"User ID = admin;" & _
"Password =;"
For more information, see: ole db provider for Microsoft Jet, Q191754, Q225048, Q239114, And Q271908
You Can Also Open An Excel Spreadsheet Using The "OLE DB Provider for Microsoft Jet"
Oconn.open "provider = microsoft.jet.Oledb.4.0;" & _
"Data Source = c: /somepath/myexcelspreadsheet.xls;" & _
"Extended Properties =" "" "" "" ""
(or named Range), So The Provider Will NOT INCLUDE THE FIRST ROW OF THE
Selection INTO The Recordset. if "HDR = no", 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 "Ole DB Provider for Microsoft Jet"
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 activity file
Ors.open "Select * from mytextfile.txt", Oconn, AdopenStatic, AdlockReadonly, AdcmdText
For more information, see: Q262537
OLE DB Provider for ODBC Databases
For access (jet):
Oconn.open "provider = msdasql;" & _
"Driver = {Microsoft Access Driver (* .mdb)};" & _
"DBQ = C: /SOMEPath/mydb.mdb;" & _
"UID = myusername;" & _
"Pwd = mypassword;"
For SQL Server:
Oconn.open "provider = msdasql;" & _
Driver = {SQL Server}; "& _
"Server = myservername;" & _
"Database = MyDatabaseName;" & _
"UID = myusername;" & _
"Pwd = mypassword;"
For more information, See: Microsoft Ole DB Provider for ODBC
OLE DB Provider for Oracle (from Microsoft)
Oconn.open "provider = msdaora;" & _
"Data Source = Myoracledb;" & _
"User ID = myusername;" & _
"Password = mypassword;" for more information, see: Microsoft Ole DB Provider for Oracle
OLE DB Provider for Oracle (from oracle)
For Standard Security:
Oconn.open "provider = oraoledb.oracle;" & _
"Data Source = Myoracledb;" & _
"User ID = myusername;" & _
"Password = mypassword;"
For A Trusted Connection:
Oconn.open "provider = oraoledb.oracle;" & _
"Data Source = Myoracledb;" & _
"User ID = /;" "& _
"Password =;"
'OR
Oconn.open "provider = oraoledb.oracle;" & _
"Data Source = Myoracledb;" & _
Osauthent = 1; "
NOTE: "Data Source =" Must Be set to the appropriate Name Which is known to the name, for ibal naming, it is the alias in the tnsnames.ora file; for oracle names, it is the the Net8 service name.
For more information, See: Connecting to an an ORACLE DATABASE
(Note, IF you get a logon Dialog, Then Click Cancel, Then Perform A One-Time Free Signup With Oracle's TechNet System)
OLE DB Provider for Simple Provider
The Microsoft Ole DB Simple Provider (OSP) Allows Ado To Access Any Data for Which a Provider HAS
Been Written Using The OLE DB Simple Provider Toolkit. Simple Providers Are Intended to Access Data
Sources That Require Only Fundamental Ole DB Support, Such as in-memory arrays or xml documents.
Osp In Mdac 2.6 Has Been Enhanced to Support Opening Hierarchical Ado Recordsets over Arbitrary
XML Files. THESE XML Files May Contain The ADO XML Persistence Schema, But it is not required. THIS
HAS BEEN IMPLEMENTED by connection the osp to the msxml2.dll, Therefore msxml2.dll or newer is
Required.oconn.open "provider = msdaosp;" & _
"Data Source = msxml2.dsoControl.2.6;"
Ors.open "http://webserver/virtualroot/myxmlfile.xml", Oconn
For more information, See: Microsoft OLE DB Simple Provider
OLE DB Provider for SQL Server
For Standard Security:
Oconn.open "provider = sqloledb;" & _
"Data Source = MyServerName;" & _
"Initial Catalog = MyDatabaseName;" & _
"User ID = myusername;" & _
"Password = mypassword;"
For A Trusted Connection:
Oconn.open "provider = sqloledb;" & _
"Data Source = MyServerName;" & _
"Initial Catalog = MyDatabaseName;" & _
Integrated Security = SSPI; "
To Connect to a "named instance" (SQL Server 2000)
Oconn.open "provider = sqloledb;" & _
"Data Source = myservername / inst2;" & _
"Initial Catalog = MyDatabaseName;" & _
"User ID = myusername;" & _
"Password = mypassword;"
To Prompt User for UserName and Password:
Oconn.Provider = "sqloledb"
Oconn.properties ("prompt") = adpromptalways
Oconn.open "Data Source = MyServerName;" & _
"InTIAL CATALOG = MyDatabaseName;"
To Connect Via An IP Address:
Oconn.open "provider = sqloledb;" & _
"Data Source = xxx.xxx.xxx.xxx, 1433;" & _
"NetWork Library = DBMSSOCN;" & _
"Initial Catalog = MyDatabaseName;" & _
"User ID = myusername;" & _
"Password = mypassword;"
Note:
- xxx.xxx.xxx.xxx is an ip address
- "NetWork Library = DBMSSOCN" TELLS OLE DB TO USE TCP / IP Rather Than Named Pipe (Q238949) - 1433 Is The Default Port Number for SQL Server
- you can also add "encrypt = yes" for Encryption
For more information, See: Microsoft Ole DB Provider for SQL Server
Remote Data Service (RDS) Connections
The Following Examples Show How To Connect To A Remote Database Using The Rds Data Control.
When Using The Rds Datacontrol's Server / SQL / Connect Properties, The Rds Datacontrol Uses The
RDS DataFactory on The Remote Server. If You Use the Rds Datacontrol's URL Property,
THEN The RDS DataFactory is Not Used At ALL.
Warning: The Rds DataFactory Can Be A Major Security Hole If Not Setup and Configured Correctly!
For more information, see rds faq # 24
RDS Datacontrol - Connect Property
With the RDS Default Handler Disabled (Not Recommend Due To Security):
With Ordc
.Server = "http:// carl2"
. SQL = "Select * from authors where stat = 'ca'"
.Connect = "provider = SQLOLED;" & _
Data Source = (local); "& _
"InTIAL CATALOG = PUBS;" & _
User ID = sa; "& _
"Password =;"
.Refresh
End with
WITH The RDS Default Handler Enabled (Recommend):
With Ordc
.Server = "http:// carl2"
.Handler = "msdfmap.handler"
.Connect = "Data Source = myconnecttag;"
. SQL = "MySQLTAG (" "CA" ")"
.Refresh
End with
The Corresponding Connect and SQL Sections in The Default Handler /winnt/msdfmap.ini File Would Be:
[Connect MyConnectTAG]
Access = readwrite
Connect = "provider = SQLOLEDB; DATA SOURCE = (local); initial catalog = public; user ID = sa; password =;" [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
RDS DataControl - URL Property
TO GET Records from a Remote Database:
With Ordc
.Url = "http://carlp0/AUTHORS_GETBYSTATE.ASP? State = CA"
.Refresh
End with
To save, SET the URL Property to an ASP Web Page:
With Ordc
.Url = "http://carlp0/rdsdatacontrol/authors_save.asp"
.Submitchanges
End with
For more information, see: RDS URL Property
ADO URL CONNECTIONS
ADO 2.5 Allows You To Open Up A RecordSet Based on XML Returned from an ASP File Over HTTP.
This Feature Doesn't Use Rds At ALL.
ADO RECORDSET
TO GET Records from a Remote Database:
Ors.open "http://carlp0/AUTHORS_GETBYSTATE.ASP? State = CA", _
AdoPenStatic, AdlockBatchOptimistic
To save changes, you must use the msxml's xmlhttp Object to post back the updated XML.
The RecordSet's Update and Updatebatch Methods Will Not Work In this case.
'Save Recordset Into Street
Set Ostm = New Adodb.Stream
Ors.save OSTM, AdpersistXML
'Use msxml's xmlhttp Object to open asp and post a xml stream
Set oxmlhttp = new msxml2.xmlhttp30
Oxmlhttp.open "pos", "http://carlp0/authors_save.asp", false
Oxmlhttp.send Ostm.ReadText
'If an error occurred
IF oxmlhttp.status = 500 THEN
Debug.print oxmlhttp.statustext
END IF
For More Information, See: Ado RecordSet's Open Method
MS Remote Provider Connections
The Following Connections Strings Use Microsoft's Remote Provider (Ms Remote). The MS RemoteProvider Tells Ado To Communicate with The Remote Server (Via the Rds DataFactory) and to use
The Remote Provider That IS Installed on The Remote Server.
Warning: The Rds DataFactory Can Be A Major Security Hole If Not Setup and Configured Correctly!
For more information, see rds faq # 24
MS Remote - Access (Jet)
If you want to use an odbc dsn on the remote machine:
Oconn.open "provider = ms remote;" & _
"Remote Server = http: // myservername;" & _
"Remote Provider = MSDasql;" & _
"DSN = Advworks;" & _
"UID = myusername;" & _
"Pwd = mypassword;"
IF you want to use an ole db provider on the remote machine:
Oconn.open "provider = ms remote;" & _
"Remote Server = http: // myservername;" & _
"Remote Provider = Microsoft.jet.Oledb.4.0;" & _
"Data Source = C: /SOMEPATH/Mydb.mdb;", _
"admin", ""
If you want to use an ole db provider on the remote machine (VIA RDS DataFactory Default Handler):
Oconn.open "provider = ms remote;" & _
"Remote Server = http: // myservername;" & _
"Handler = msdfmap.handler;" & _
"Data Source = myadvworksconn;"
The corresponding entry in /winnt/msdfmap.ini file would be:
[Connect myadvworksconn]]
Access = readwrite
Connect = "provider = Microsoft.jet.Oledb.4.0;" & _
"Data Source = mydb.mdb;" & _
"User ID = admin;" & _
"Password =;"
MS Remote - SQL Server
If you want to use an odbc dsn on the remote machine:
Oconn.open "provike;" & _ "remote server = http: // myservername;" & _
"Remote Provider = MSDasql;" & _
DSN = MyDatabaseName; "& _
"UID = myusername;" & _
"Pwd = mypassword;"
IF you want to use an ole db provider on the remote machine:
Oconn.open "Remote Provider = MS Remote;" & _
"Remote Server = http: // myservername;" & _
"Provider = SQLOLEDB;" & _
"Data Source = MyServerName;" & _
"Initial Catalog = MyDatabaseName;" & _
"User ID = myusername;" & _
"Password = mypassword;"
If you want to use an ole db provider on the remote machine (VIA RDS DataFactory Default Handler):
Oconn.open "provider = ms remote;" & _
"Remote Server = http: // myservername;" & _
"Handler = msdfmap.handler;" & _
"Data Source = MyPubsconn;"
The corresponding entry in /winnt/msdfmap.ini file would be:
[Connect MyPubsconn]]
Access = readwrite
Connect = "provider = SQLOLEDB;" & _
"Data Source = MyServerName;" & _
"Initial Catalog = MyDatabaseName;" & _
"User ID = myusername;" & _
"Password = mypassword;"
For more information, see: Microsoft Ole DB Remoting Provider and Q240838
Data Shape Provider Connections
MS Datashape - SQL Server
Oconn.open "provider = msdatashape;" & _
"Data provider = SQLOLEDB;" & _
"Data Source = mysqlservername;" & _
"InTIAL CATALOG = MyDatabase;" & _
"User ID = myusername;" & _
"Password = mypassword;"
THEN USE A Shape Command with SQL STRINGS: SSQL = "Shape {Select * from authors}" & _
Append ({Select * from titleauthor} as chapter "& _
"Relate au_id to au_id)"
OR Use a Shape Command That Calls Stored Procedures:
SSQL = "Shape {EXEC Spauthors_loadAll}" & _
Append ({EXEC SPTITLEAUTHOR_LOADALL} as chapter "& _
"Relate au_id to au_id)"
For more information, see: Microsoft Data Shaping Service for ole db and q288409
.NET Managed Provider Connections
SQL Client .NET Managed Provider (System.Data.sqlclient)
The SQL Client .Net Managed Provide Allows You To Connect To A Microsoft SQL Server 7.0
OR 2000 Database. for Microsoft SQL Server 6.0 or Earlier, Use the Ole DB .NET DATA Provider
With the "SQL Server Ole DB Provider".
Dim OsqlConnection As Sqlclient.sqlConnection
DIM SCONNSTRING AS STRING
Sconnstring = "Data Source = (local);" & _
"Initial catalog = northwind;" & _
Integrated Security = SSPI; "& _
"Pooling = true;" & _
"MIN pool size = 10;" & _
"Max pool size = 50;" & _
"Connection Lifetime = 30;" & _
"Connection Reset = True;" & _
Enlist = true; "
OsqlConnection = New SqlClient.sqlConnection (Sconnstring)
OsqlConnection.Open ()
For more information, see: system.data.sql namespace and .net data providers
Note: 'SQL' Namespace Got Renamed To 'Sqlclient'
OLE DB .NET Managed Provider (System.Data.Oledb)
The OLE DB .NET DATA Provider Uses Native Ole DB THROUGH COM Interop To Enable Data Access.
To Use the OLE DB .NET DATA Provider, You Must Also Use An Ole DB Provider (E.G. Sqloledb, Msdaora, or Microsoft.jet.Oledb.4.0).
For SQL Server Ole DB Provider (for SQL Server 6.0 or Earlier)
DIM OLDBCONNECTION AS OLEDB.OLEDBCONNECTION
DIM SCONNSTRING AS STRING
Sconnstring = "provider = sqloledb;" & _
"Data Source = MyServerName;" & _
"Initial Catalog = MyDatabaseName;" & _
"User ID = myusername;" & _
"Password = mypassword;"
Ooledbconnection = new oledb.oledbconnection (sconnstring)
Ooledbconnection.Open ()
For Jet OLE DB Provider:
DIM OLDBCONNECTION AS OLEDB.OLEDBCONNECTION
DIM SCONNSTRING AS STRING
Sconnstring = "provider = microsoft.jet.Oledb.4.0;" & _
"Data Source = C: /Work/nwind.mdb;" & _
"User ID = admin;" & _
"Password =" ";"
Ooledbconnection = new oledb.oledbconnection (sconnstring)
Ooledbconnection.Open ()
For more information, see: system.data.oledb namespace and .net data providers
Note: 'ADO' Namespace Got Renamed to 'OLEDB'
ODBC .NET Managed Provider (System.Data.odbc)
The ODBC .NET DATA Provider is an add-on component to the .NET Framework SDK Beta 2.
IT Provides Access To Native Odbc Drivers The Same Way The OLE DB .NET DATA PROVIDER
Provides Access to Native Ole DB Providers.
For SQL Server ODBC DRIVER:
DIM ODBCCONNECTION As ODBC.ODBCCONNECTION
DIM SCONNSTRING AS STRING
'Create and Open A New ODBC Connection
Sconnstring = "driver = {SQL Server};" & _
"Server = mysqlservername;" & _
"Database = MyDatabaseName;" & _
"UID = myusername;" & _
"Pwd = mypassword;" oodbcconnection = new odbc.odbcconnection (sconnstring)
Oodbcconnection.Open ()
For Oracle ODBC DRIVER:
DIM ODBCCONNECTION As ODBC.ODBCCONNECTION
DIM SCONNSTRING AS STRING
'Create and Open A New ODBC Connection
Sconnstring = "driver = {microsoft odbc for oracle};" & _
"Server = oracleserver.world;" & _
"UID = myusername;" & _
"Pwd = mypassword;"
Oodbcconnection = new odbc.odbcconnection (sconnstring)
Oodbcconnection.Open ()
For Access (JET) ODBC Driver:
DIM ODBCCONNECTION As ODBC.ODBCCONNECTION
DIM SCONNSTRING AS STRING
'Create and Open A New ODBC Connection
Sconnstring = "Driver = {Microsoft Access Driver (* .mdb)};" & _
"DBQ = C: /SOMEPath/mydb.mdb;" & _
"Uid = admin;" & _
"Pwd =;"
Oodbcconnection = new odbc.odbcconnection (sconnstring)
Oodbcconnection.Open ()
For All Other ODBC Drivers:
DIM ODBCCONNECTION As ODBC.ODBCCONNECTION
DIM SCONNSTRING AS STRING
'Create and Open A New ODBC Connection
Sconnstring = "DSN = MyDSN;" & _
"UID = myusername;" & _
"Pwd = mypassword;"
Oodbcconnection = new odbc.odbcconnection (sconnstring)
Oodbcconnection.Open ()