Database connection string
In various application development of the database, the connection database is the first step in database application development, and it is also the most important step. For different databases, their connection modes are different, and the corresponding connection strings are different.
Programmers may have such experiences, sometimes I don't know how to write or write the connection string to the database, causing the database that cannot be properly accessed. Of course, many programming tools can directly generate the correct connection string through visual interface, but the specific meaning of each parameter in the string is not clear, often confused. This article lists the connection string required for different connection methods for most common databases, so that the programmer reference!
SQL Server
· ODBC
o Standard security:
"Driver = {SQL Server}; server = aron1; data = pubs; uid = sa; pwd = asdasd;"
1) When the server is local when the server is local; local;
"Driver = {SQL Server}; server = (local); database = pubs; uid = sa; pwd = asdasd;"
2) When connecting the remote server, you need to specify an address, port number, and a network library.
"Driver = {SQL Server}; server = 130.120.110.001; address = 130.120.110.001, 1052; network = dbmssocn; database = pubs; uid = sa; pwd = asdasd;"
Note: The Address parameter must be an IP address, and must include a port number.
o Trusted Connection: (Microsoft Windows NT integrates security)
"Driver = {SQL Server}; server = aron1; database = pubs; trusted_connection = yes;"
or
"Driver = {SQL Server}; server = aron1; database = pubs; uid =; pwd =;"
o Popked the username and password dialog box when connecting:
Conn.properties ("prompt") = adpromptalways
Conn.open "driver = {SQL Server}; server = aron1; database = public;"
· OLE DB, OLEDBCONNECTION (.NET)
o Standard security:
"Provider = sqloledb; data source = aron1; initial catalog = pubs; user ID = sa; password = asdasd;"
o Trusted Connection:
"Provider = sqloledb; data source = aron1; initial catalog = pubs; integrated security = SSPI;
(If connected to a specific named SQLServer instance, using Data Source = Servere Name / Instance Name; but only for the SQLServer2000), for example: "Provider = sqloledb; Data Source = MyServerName / MyInstanceName; Initial Catalog = MyDatabaseName; User Id = MyUsername Password = mypassword; "O" O connections pop-up input username and password dialog:
Conn.Provider = "sqloledb"
Conn.properties ("prompt") = adpromptalways
Conn.open "Data Source = aron1; initial catalog = pubs;"
o Connect to the IP address:
"Provider = SQLOLEDB; DATA SOURCE = 190.190.200.100, 1433; network library = dbmssocn; initial catalog = pubs; user ID = sa; password = asdasd;"
(DBMSSOCN = TCP / IP instead of NAMED PIPES, the end number required for Data Source is required (default 1433)))
SqlConnection (.NET)
o Standard security:
"Data Source = aron1; initial catalog = pubs; user ID = sa; password = asdasd;"
or
"Server = aron1; database = pubs; user ID = sa; password = asdasd; trusted_connection = false"
(The result of these two connection strings is the same)
o Trusted Connection:
"Data Source = aron1; initial catalog = pubs; integrated security = sspi;"
or
"Server = aron1; database = pubs; trusted_connection = true;"
(The result of these two connection strings is the same)
(You can use ServerName / InstanceName to replace Data Source, take the value of a specific SQLServer instance, but only for SQLServer2000)
o Connect to the IP address:
"Data Source = 190.190.200.100, 1433; network library = dbmsoCN; Initial catalog = pubs; user ID = sa; password = asdasd;"
(DBMSSOCN = TCP / IP instead of NAMED PIPES, the end number required for Data Source is required (default 1433)))
o SqlConnection connection declaration:
C #:
Using system.data.sqlclient;
SqlConnection SQLCONN = New SqlConnection ();
Sqlconn.connectionstring = "my connectionstring";
Sqlconn.open ();
VB.NET:
Imports system.data.sqlclient
DIM SQLCONN AS SQLCONNECTION = New SqlConnection () Sqlconn.connectionstring = "My Connectionstring"
Sqlconn.open ()
· Data Shape
o MS Data Shape
"Provider = msdatashape; data provides = sqloledb; data source = aron1; initial catalog = pubs; user ID = sa; password = asdasd;"
· More
o How to define which protocol to use
§ Example:
"Provider = SQLOLEDB; DATA SOURCE = 190.190.200.100, 1433; network library = dbmssocn; initial catalog = pubs; user ID = sa; password = asdasd;"
Name Network Agreement Library
DBNMPNTW WIN32 NAMED PIPES
DBMSSOCN WIN32 WINSOCK TCP / IP
DBMSSPXN WIN32 SPX / IPX
DBMSVINN WIN32 Banyan Vines
DBMSRPCN WIN32 MULTI-Protocol (Windows RPC)
§ important hint
Use the following syntax when connecting through the SQLOLEDB provider:
Network library = dbmsocco
However, the following syntax is used by the MSDasql provider:
Network = dbmssocn
o All SQLConnection connection string properties
§ The following table shows all the connection string properties of the ADO.NET SQLConnection object. Most of the properties are also used in ADO. All attributes and descriptions come from MSDN.
Name Default Value Description
Application Name Application Name or when the application is not provided, a .NET SQLCLIENT data provider
AttachDbFileName or Extended Properties or the name of the primary file name, including the full path to the associated database. The database name must be specified by keyword 'database'.
Connect TimeOut or Connection Timeout 15 When the connection request is aborted, wait for the server to wait for the server to connect (in seconds)
Connection Lifetime 0 When a connection returns to the connection pool, the current time and connection creation time, if the time period exceeds the specified connection time, this connection is destroyed. It is used to force load balancing between running servers and ready-to-line servers in aggregate settings.
Connection Reset 'True' When the connection is removed from the connection pool, it is decided to reset the database connection. When set to 'false', it is used to avoid the additional server to get a connection.
CURRENT LANGUAGE SQL Server Language Record Name
Data Source or Server or Addr or Addr or NetWork Address's name or network address of the SQL Server instance to connect
Enlist 'true' is true, the connection pool automatically lists the connections in the current transaction context of the thread.
Initial Catalog or Database Database Name
Integrated Security or Trusted_Connection 'false' is connected to a trust connection. Its value is 'True', 'false' and 'sspi' (equal to 'TRUE'). Max Pool Size 100 The maximum number of connections allowed in the pool
MIN POOL SIZE 0 Connect the minimum connection allowed in the pool
The Network library or net 'dbmsoCN' network library is used to establish a connection with an SQL Server instance. The value includes DBNMPNTW, DBMSRPCN (Multi-Protocol), DBMsadSn (Apple Talk), DBMSGNET (VIA), DBMSIPCN (Shared Memory), and DBMSSPXN (IPX / SPX), and DBMSSOCN (TCP / IP). The corresponding dynamic link library must be installed. If you don't specify a network, you will use a local server (for example, ",", "), will use Shared Memory
Packet size 8192 network package byte size with an instance of SQL Server
Password- or PWD SQL Server account login password
Persist security info 'false' is set to 'false', when the connection has been turned on or is in an open state, the sensitivity security information (such as password) does not return a part of the connection as a connection.
Pool 'true' is true, remove the SqlConnection object from the appropriate connection pool, or create a SQLConnection object if necessary and increase it to the appropriate connection pool.
User ID SQL Server Login User
WorkStation ID The Local Computer Name Connect to SQL Server Workstation Name
§ Note:
Separate each attribute using a semicolon
If a name is more than twice, the value in the last occurrence of the connection string will be used.
If you build a connection string by entering the value of the field in the app, you must ensure that the user does not insert an additional attribute through another value in the user value to change the connection string.
ACCESS
· ODBC
o Standard security:
"Driver = {Microsoft Access Driver (* .mdb)}; dbq = c: /mydatabase.mdb; uid = admin; pwd =;"
O group (system database): Workgroup:
The two methods are: specify the username and password in the connection string or in the open data set.
"Driver = {Microsoft Access Driver (* .mdb)}; dbq = c: /mydatabase.mdb; systemdb = c: /mydatabase.mdw;", "admin", ""
or
IF (PDB.Open ("Driver = {Microsoft Access Driver (* .mdb)}; dbq = c: /mydatabase.mdb; systemdb = c: /mydatabase.mdw;", "", "databaseuser", "databasepass" ))
{DOSMETHING ();
PDB.Close ();
}
o Exclusive (Exclusive):
"Driver = {Microsoft Access Driver (* .mdb)}; DBQ = C: /MyDatabase.mdb; Exclusive = 1; UID = admin; pwd =" · OLE DB, OLEDBCONNECTION (.NET)
o Standard security:
"Provider = microsoft.jet.Oledb.4.0; data source = / somepath / mydb.mdb; user ID = admin; password =;"
O group connection (system database)
"Provider = microsoft.jet.Oledb.4.0; data source = / somepath / mydb.mdb; jet oledb: system database = system.mdw;", "admin", ""
o A connection to the password:
"Provider = microsoft.jet.Oledb.4.0; data source = / somepath / mydb.mdb; jet oledb: Database password = mydbpassword;", "admin", ""
· Oracle
· ODBC
o New version:
"Driver = {microsoft odbc for oracle}; server = oracleserver.world; uid = username; pwd = asdasd;"
o Older version:
"Driver = {microsoft odbc driver for oracle}; connectionString = oracleserver.world; uid = myusername; pwd = mypassword;"
· OLE DB, OLEDBCONNECTION (.NET)
o Standard security:
"Provider = msdaora; data source = myoracledb; user id = username; password = asdasd;"
This is the format of Microsoft, the following is the format of Oracle (the provider is different)
"Provider = oraoledb.oracle; data source = myoracledb; user ID = username; password = asdasd;"
Note: "Data Source =" must be set to NET8 name according to the corresponding naming method. For example, for local naming, it is the alias in tnsnames.ora, named Oracle, is Net8 network service name
o Trusted Connection:
"Provider = oraoledb.racle; data source = myoracledb; osauthent = 1;"
Or set the USER ID "/"
"Provider = oraoledb.racle; data source = myoracledb; user ID = /; password =;"
· OracleConnection (.NET)
o Standard connection:
"Data Source = Oracle8i; Integrated Security = YES"; this is only valid for Oracle 8i Release 3 or higher
o OracleConnection declaration:
C #:
Using system.data.oraclient;
OracleConnection OracleConn = New OracleConnection ();
Oracleconn.connectionstring = "my connectionstring";
Oracleconn.open ();
VB.NET:
Imports system.data.OracleClient
Dim OracleConn as OracleConnection = New OracleConnection ()
OracleConn.connectionstring = "my connectionstring"
Oracleconn.open ()
· Data Shape
o MS Data Shape:
"Provider = msdatashape.1; Persist security info = false; data source = msdara; data source = ORAC; user ID = username; password = mypw"
· Mysql
· ODBC
o Local Database:
"Driver = {mysql}; server = mysrvname; option = 16834; Database = mydatabase;"
The Sever parameter can also use localhost as its value.
o Remote database:
"Driver = {mysql}; server = data.domain.com; port = 3306; option = 131072; stmt =; dataBase = my-data; uid = username; pwd = password;"
Option value
1 The client cannot handle myODBC to return a column of true width
2 The client cannot handle the true value of the row of MySQL returns the row of the impact, and MySQL returns 'Found Rows'. MySQL 3.21.14 or update version can take effect
4 Generate a debug log in C: /Myodbc.log. This is the same as the setting mysql_debug = d: t: o, c :: / myodbc.log
8 Do not set any package restrictions on the results and parameters
16 Do not bring the drive to the problem
32 Use or remove dynamic cursor support. This is not allowed in myodbc 2.50
64 Using the use of the database name in 'Database.table.column'
128 Forced ODBC Manager Cursor
256 Remove the use of extension (FETCH)
512 full of char fields full length
1024 SQLDESCRIBECOL () Function Returns the column name that fully meets the conditions
2048 Using Compressed Server / Client Protocol
4096 Tell the server after the function and '(' ignoring the space before '(PowerBuilder needs). This will generate all function name keywords
8192 Using a Named Pipe Connection Mysqld Server on NT
16384 Change the longlong column to an INTL column (some applications cannot handle the longlong column)
32768 Return 'User' from SqlTables as Table_Qualifier and Table_owner
66536 read the parameters from the client, read the ODBC group from `my.cnf '
131072 Add some additional safety inspection
If you need a lot of options, you should add the above flags. · OLE DB, OLEDBCONNECTION (.NET)
o Standard connection:
"Provider = mysqlprov; data source = mydb; user id = username; password = asdasd;"
Data Source is the name of the MySQL database, or server = localhost; db = test
· MySQLConnection (.NET)
o einfodesigns.dbProvider:
"Data Source = Server; Database = MYDB; User ID = Username; Password = PWD; Command logging = false"
Only for Einfodesigns dbProvider, attached to .NET
o MySQLConnection declaration:
C #:
Using einfodesigns.dbprovider.mysqlclient;
MySQLConnection mysqlconn = new mysqlconnection ();
MySQLConn.connectionstring = "my connectionstring";
Mysqlconn.open ();
VB.NET:
Imports einfodesigns.dbProvider.mysqlclient
DIM mysqlconn as mysqlconnection = new mysqlconnection ()
Mysqlconn.connectionstring = "My Connectionstring"
Mysqlconn.open ()
· Interbase
· ODBC, EASYSOFT
o Local computer:
"Driver = {easysoft IB6 odbc}; server = localhost; database = localhost: c: /mydatabase.gdb; uid = username; pwd = password
o Remote computer:
"Driver = {easysoft IB6 odbc}; server = computername; database = computername: c: /mydatabase.gdb; uid = username; pwd = password
· ODBC, INTERSOLV
o Local computer:
"Driver = {INTERSOLV Interbase ODBC Driver (* .GDB)}; server = localhost; database = localhost: c: /mydatabase.gdb; uid = username; pwd = password
o Remote computer:
"Driver = {INTERSOLV InterBase ODBC Driver (* .GDB)}; server = computername; Database = computename: c: /mydatabase.gdb; uid = username; pwd = password
This drive is now available by DataDirect Technologies (provided by INTERSOLV)
· OLE DB, SIBPROVIDER
o Standard connection:
"provider = sibprovider; location = localhost:; data source = c: /databases/gdbs/mygdb.gdb; user ID = sysdba; password = masterkey" o Specified character set:
"provider = sibprovider; location = localhost:; data source = c: /Databases/gdbs/mygdb.gdb; user ID = sysdba; password = masterkey; character set = iso8859_1
o Specify the role:
"provider = sibprovider; location = localhost:; data source = c: /databases/gdbs/mygdb.gdb; user ID = sysdba; password = masterkey; role = digitadores
· Need to get more please link to Interbase, the following Borland developer network article
Http://community.borland.com/Article/0,1410,27152,00.html
· IBM DB2
· OLE DB, OLEDBCONNECTION (.NET) from MS
o TCP / IP:
"Provider = DB2OLEDB; Network Transport Library = TCPIP; Network Address = XXX.XXX.XXX.XXX; Initial Catalog = MyCtlg; Package Collection = MyPkgCol; Default Schema = Schema; User ID = MyUser; Password = MyPW"
o appc:
"Provider = DB2OLEDB; APPC Local LU Alias = MyAlias; APPC Remote LU Alias = MyRemote; Initial Catalog = MyCtlg; Package Collection = MyPkgCol; Default Schema = Schema; User ID = MyUser; Password = MyPW"
AS400
· ODBC
"Driver = {Client Access ODBC Driver (32-bit)}; system = myas400; uid = myusername; pwd = mypassword
· OLE DB, OLEDBCONNECTION (.NET)
"Provider = IBMDA400; Data Source = MyAS400; user ID = myusername; password = mypassword;"
· Sybase
· ODBC
o Sybase system 12 (or 12.5) Enterprise Open Client standard connection:
"Driver = {Sybase ASE ODBC Driver}; SRVR = aron1; uid = username; pwd = password"
o Sybase system 11 standard connection:
"Driver = {Sybase System 11}; SRVR = aron1; uid = username; pwd = password;"
o INTERSOLV 3.10:
"Driver = {INTERSOLV 3.10 32-bit sybase}; SRVR = aron1; uid = username; pwd = password;" o Sybase SQL Anywhere ": Watcom SQL ODBC Driver:
"ODBC; driver = sybase sql anywhere 5.0; defaultdir = c: / dbfaulter /; dbf = c: /mydatabase.db; uid = username; pwd = password; dsn =" "" "
Note: For dual quotes (VB syntax) referenced at the end, you must change the reference symbol syndrome specified by the language you use. The DSN parameter is actually very important, and if not included, the 7778 error will be caused.
· OLE DB
o Adaptive Server Anywhere (ASA):
"Provider = asaprov; data source = myasa"
o Adaptive Server Enterprise (ASE) (with data source is .IDS file):
"Provider = Sybase ASE OLE DB Provider; Data Source = Myase"
Note You must use Data Manager to create a data source .ids file. These .ids files are similar to ODBC DSNs.
Visual FoxPro (DBASE)
· ODBC
o DBASE:
"Driver = {Microsoft DBase Driver (* .dbf)}; driverid = 277; DBQ = C: // DatabasePath"
Note You must specify a file name (such as "Select Name, Address from Clients.dbf" when writing SQL statements.
o Visual FoxPro (with database containers):
"Driver = {Microsoft Visual FoxPro Driver}; UID =; SourceType = DBC; SourceDb = C: //DatabasePath/MyDatabase.dbc; Exclusive = NO"
o Visual FoxPro (no agriculture container):
"Driver = {Microsoft Visual FoxPro Driver}; UID =; SourceType = DBF; SourceDb = C: //DatabasePath/MyDatabase.dbc; Exclusive = NO"
· OLE DB, OLEDBCONNECTION (.NET)
o Standard connection:
"Provider = vfpoledb; data source = c: //databasepath/Mydatabase.dbc;"
Excel
· ODBC
o Standard security:
"Driver = {Microsoft Excel Driver (* .xls)}; driverid = 790; dbq = c: //databasePath//dbspreadsheet.xls; defaultdir = c: // DatabasePath;"
· OLE DB Provider for Microsoft Jet
o Standard security:
"Provider = microsoft.jet.OLEDb.4.0; data source = c: //databasePath//dbspreadsheet.xls; extended proties = /" / "Excel 8.0; HDR = yes; /" / ";" Note: If "HDR = YES, then the provider does not include the first line of the selected selection in the recordset, if, the provider will include the first line of the unit range (or have named) in the recordset.
TEXT
· ODBC
o Standard security:
"Driver = {Microsoft text driver (* .txt; * .csv)}; dbq = c: // DatabasePath //; extensions = ASC, CSV, Tab, TXT;"
If the text file uses Tab as a separator, you must create a schema.ini file, you must use the format = tabdelimited option in the connection string.
Note: You must specify a file name in the SQL statement (such as "SELECT NAME, Address from Clients.csv")
· OLE DB Provider for Microsoft Jet
o Standard security:
"Provider = microsoft.jet.Oledb.4.0; data source = c: // DatabasePath //; extended proties = /" / "text;" HDR = yes; fmt = DELIMITED; / "/"; "
Note You must specify the file name (such as "Select Name, Address from Clients.txt" when writing SQL statements.
ODBC DSN
"DSN = mydsn; uid = myusername; pwd = mypassword;"
OLE DB Provider for ODBC Databases
Connect Access:
"Provider = msdasql; driver = {microsoft access driver (* .mdb)}; dbq = c: //database.mdb; uid = myusername; pwd = mypassword;"
Connect to SQL Server:
"Provider = msdasql; driver = {sql server}; server = myservername; database = mydatabaseename; uid = myusername; pwd = mypassword;"
Use DSN to connect:
"Provider = msdasql; persistSecurityInfo = false; trusted_connection = yes; data source = mydsn; catalog = mydatabase;"
OLE DB Provider for OLAP
"Provider = msolap; data source = myolapservername; initial catalog = myolapdatabaseename;"
Connection via HTTP:
This feature allows the client application to specify a URL in the Data Source parameter of the client application connection string and connect to an analytical server using IIS. This connection method allows the PivotTable service to connect to the analysis server via a firewall or proxy server. A special ASP page MSOLAP.ASP is connected via IIS. When connected to the server, this file must be in this directory and as part of the URL (eg http://www.myserver.com/myolap/).
Use the URL connection:
"Provider = msolap; data source = http: // myolapservername /; initial catalog = myolapdatabaseename;"
Use SSL connections:
"Provider = msolap; data source = https: // myolapservername /; initial catalog = myolapdatabaseename;"
OLE DB Provider for Active Directory
"Provider = adsdsoobject; user ID = myusername; password = mypassword;"
OLE DB Provider for Index Server
"provider = msidxs; data source = mycatalog;"
OLE DB DATA LINK CONNECTIONS
File name = c: //databasepath//database, "
Outlook 2000 Personal Mail Box
"Provider = microsoft.jet.Oledb.4.0; Outlook 9.0; mapilevel =; dataBase = C: // Temp //;"
Use any temporary folder instead of C: / TEMP. This will create a schema file in that folder, when you open it, it displays all the fields that can be obtained. Empty mapilevel indicates the highest layer folder.
Exchange mail box
"Provider = microsoft.jet.Oledb.4.0; Exchange 4.0; mapilevel = mailbox - Pat Smith |; Database = C: // Temp //;"
Use any temporary folder instead of C: / TEMP.
Note: You can enter the Mail Store as the database.
Example: "SQL" Select Contacts. * From Contacts; "
script>
script>
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 (from Microsoft) VSAM 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 (from Microsoft) Oracle OLE DB Provider for Oracle (from Oracle) OLE DB Provider for Pervasive OLE DB Provider for Simple Provider OLE DB Provider for SQLBase OLE DB Provider for SQL Server OLE DB Provider for SQL Server VIA SQLXMLOLEDB OLE DB Provider for Sybase Adaptive Server Anywhere OLE DB Provider for Sybase Adaptive Server Enterprise Ole DB Provider for Text Files Ole DB Provider for Unidat A and Universes Ole DB Provider for Visual FoxProle 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 To View Microsoft Kb Articles Related To Data Link File, Click Here
OLE DB Provider for Advantage Oconn.open "provider = Advantage Ole DB Provider;" & _
"Data Source = C: / MyDbftableDir;" & _
"Servertype = ads_local_server;" & _
"TableType = Ads_CDX" for more information, see: Advantage Ole DB Provider (for ado)
OLE DB Provider for AS / 400 (from IBM) 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 AS / 400 and vsam (from microsoft) Oconn.open "provider = snaoledb;" & _
"Data Source = myas400;" & _
"User ID = myusername;" & _
"Password = mypassword" for more information, see: Connectionstring Property to View Microsoft KB Articles Related to Ole DB Provider for AS / 400 And Vsam, Click Here
OLE DB Provider for Commerce Server for Data Warehouseoconn.open "provider = Commerce.dso.1;" & _
"Data Source = mscop: // Inprocconn / Server = MySRVNAME:" & _
"Catalog = DWSCHEMA: Database = MyDBName:" & _
"User = myusername: Password = mypassword:" & _
"Fastload = true"
'OR
Oconn.open "URL = mscop: // Inprocconn / Server = MyServerName:" & _
"Database = mydbname: catalog = dwschema:" & _
"User = myusername: Password = mypassword:" & _
"Fastload = true"
For profiling systemoconn.open "provider = commece.dso.1;" & _
"Data Source = mscop: // Inprocconn / Server = MySRVNAME:" & _
"Catalog = Profile Definitions: Database = MyDBName:" & _
"User = myusername: password = mypassword"
'OR
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 hereOLE DB Provider for DB2 (from Microsoft ) For tcp / ip connectsoconn.open = "provider = db2oledb;" & _
"NetWork Transport Library = TCPIP;" & _
"NetWork address = xxx.xxx.xxx.xxx;" & _
"InTIAL CATALOG = Mycatalog;" & _
Package Collection = MypackageCollection; "& _
Default Schema = myschema; "& _
"User ID = myusername;" & _
"Password = mypassword"
For appc connectionsoconn.open = "provider = db2oledb;" & _
Appc Local Lu Alias = MYLOCALLUALIAS; "& _
Appc Remote Lu Alias = MyRemoteLias; "& _
"InTIAL CATALOG = Mycatalog;" & _
Package Collection = MypackageCollection; "& _
Default Schema = myschema; "& _
"User ID = myusername;" & _
"Password = mypassword" for more information, see: connectionstring property, and q218590 to view Microsoft KB Articles Related To Ole DB Provider for DB2, Click Here
OLE DB Provider for DTS Packages The Microsoft OLE DB Provider for DTS Packages is a read-only provider that exposes Data Transformation Services Package Data Source Objects.oConn.Open = "Provider = DTSPackageDSO;" & _
"Data Source = MyDataSource"
For more information, See: Ole DB Providers Tested with SQL Server To View Microsoft KB Articles Related To Ole DB Provider for DTS Packages, Click Here
OLE DB Provider for Exchange oConn.Provider = "EXOLEDB.DataSource" oConn.Open = "http: // myServerName / myVirtualRootName" For more information, see: Exchange OLE DB Provider, Messaging, Calendaring, Contacts, and Exchange using ADO objects To View Microsoft KB Articles Related To Ole DB Provider for Exchange, Click Here
OLE DB Provider for Excel Currently Excel Does Not Have An Ole DB Provider. However, You CAN Use The Odbc Driver For Excel. Or Use The Ole DB Provider for Jet To Read and Write Data in An Excel Workbook.
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 To View Microsoft Kb Articles Related To Ole DB Provider for Index Server, Click Here
OLE DB Provider for Internet Publish Oconn.open "provider = msdaipp.dso;" & _
"Data Source = http: // mywebsite / mydir;" & _
"User ID = myusername;" & _
"Password = mypassword" 'or oponn.open "URL = http: // mywebsite / mydir;" & _
"User ID = myusername;" & _
"Password = mypassword" for more information, see: Microsoft Ole DB Provider for Internet Publishing and Q245359 To View Microsoft KB Articles Related To Ole DB Provider for Internet Publishing, Click Here
OLE DB Provider for Microsoft Jet for Standard Securityoconn.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 "Province" provider = microsoft.jet.Oledb.4.0; "& _" data source = c: /somepath/mydb.mdb; "& _
"Jet OLEDB: System Database = mysystem.mdw", _
"MyUsername", "myPassword" Note, remember to convert both the MDB and the MDW to the 4.0database format when using the 4.0 OLE DB Provider If MDB has a database passwordoConn.Open "Provider = Microsoft.Jet.OLEDB.4.0.; "& _
"Data Source = C: /SOMEPATH/Mydb.mdb;" & _
"Jet OLEDB: Database Password = MyDbpassword", _
"myusername", "mypassword"
IF Want to Open Up The MDB Exclusivelyoconn.Mode = AdmodeshareExClusive
Oconn.open "provider = microsoft.jet.Oledb.4.0;" & _
"Data Source = C: /SOMEPATH/Mydb.mdb;" & _
"User ID = admin;" & _
"Password ="
IF mdb is located on a network shareoconn.open "provider = microsoft.jet.Oledb.4.0;" & _
"Data Source = // myserver / myshare / mypath / mydb.mdb"
IF MDB Is Located on A Remote Machine - Or Use An XML Web Service Via SOAP Toolkit Or ASP.NET- or UPGRADE TO SQL Server and Use An Ado Url with a Remote ASE An Ado Url Use A MS Remote or Rds Connection String if you don't know the path to the mdb (using asp) <% 'ASP Server-Side Code
Oconn.open "provider = microsoft.jet.Oledb.4.0;" & _
"Data Source =" & Server.mappath (".") & "/Mydb.mdb;"
"User ID = admin;" & _
"Password ="
%> 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. If you do not know the path to the MDB (using VB) oConn.Open " Provider = microsoft.jet.OleDb.4.0; "& _" data source = "& app.path &" /mydb.mdb; "& _
"User ID = admin;" & _
"Password =" This assumes the MDB is in the same directory where the application is running For more information, see:. OLE DB Provider for Microsoft Jet, Q191754, and Q225048 Note: Microsoft.Jet.OLEDB.3.51 only gets installed by MDAC . 2.0 Q197902Note:. MDAC 2.6 and 2.7 do not contain any of the JET components Q271908 and Q239114 to view Microsoft KB articles related to OLE DB Provider for Microsoft JET, click here 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 theselection into the recordset If "HDR = No", then the provider will includethe 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 fileoRs.Open "Select * From MyTextFile.txt", oConn, _adOpenStatic, adLockReadOnly, adCmdText For More information, see: Q262537
OLE DB Provider for Microsoft Project Oconn.open "provider = microsoft.project.Oledb.9.0;" & _
"Project Name = c: /somepath/myProject.mpp" For more information, see: Microsoft Project 2000 OLE DB Provider Information To view Microsoft KB articles related to OLE DB Provider for Microsoft Project, click here
OLE DB Provider for MySQL OCONN.Open "provider = mysqlprov;" & _
"Data Source = mysqldb;" & _
"User ID = myusername;" & _
"Password = mypassword" for more information, see: API - OLE DB and SNIPPET
OLE DB Provider for ODBC Databases Warning: This Ole DB Provider is considered ObsoleTe by Microsoft! For Access (Jet) Oconn.open "provider = msdasql;" & _
"Driver = {Microsoft Access Driver (* .mdb)};" & _
"DBQ = C: /SOMEPath/mydb.mdb;" & _
"UID = myusername;" & _
"Pwd = mypassword"
For SQL Serveroconn.open "provider = msdasql;" & _
Driver = {SQL Server}; "& _
"Server = myservername;" & _
"Database = MyDatabaseName;" & _
"UID = myusername;" & _
"Pwd = mypassword" for more information, see: Microsoft Ole DB Provider for ODBC to View Microsoft KB Articles Related To Ole DB Provider for ODBC, Click Here
OLE DB Provider for OLAP Services Microsoft OLE DB for Online Analytical Processing (OLAP) is a set of objects and interfaces that extends the ability of OLE DB to provide access to multidimensional data stores. For ADOMD.CatalogoCat.ActiveConnection = _ "Provider = MSOLAP ; "& _
"Data Source = myolapservername;" & _
"Initial Catalog = MyolapdatabaseName"
For adomd.catalog (with url) ocat.activeConnection = _
"Provider = msolap;" & _
"Data Source = http: // myservername /;" & _
"Initial Catalog = MyolapdatabaseName"
For Excel Pivottablewith ActiveWorkbook.Pivotcaches.add (SourceType: = XLExternal)
.Connection = "OLEDB;" & _
"Provider = msolap;" & _
"Location = MyServerDataLocation;" & _
"Initial Catalog = MyolapdatabaseName"
.MAINTAINCONNECONNECTION = TRUE
.CreatePivottable TableDestination: = Range ("A1"), _
TableName: = "MyPivottablename"
End with
For More Information, See: Ole Db for OLAP, Catalog Object, Pivottable, Connecting Using Http to View Microsoft Kb Articles Related To Ole DB Provider for Olap Services, Click Here
OLE DB Provider for Oracle (from Microsoft) Oconn.open "provider = msdara;" & _
"Data Source = Myoracledb;" & _
"User ID = myusername;" & _
"Password = mypassword" for more information, see: Microsoft Ole DB Provider for Oracle To View Microsoft Kb Articles Related To Ole DB Provider For Oracle, Click Here
OLE DB Provider for Oracle (from Oracle) for Standard Securityoconn.open "provider = Oraoledb.oracle;" & _
"Data Source = Myoracledb;" & _
"User ID = myusername;" & _ "password = mypassword"
For a trusted connectionoconn.open "provider = oraoledb.oracle;" & _
"Data Source = Myoracledb;" & _
"User ID = /;" "& _
"Password ="
'Oroconn.open "provider = oraoledb.racle;" & _
"Data Source = Myoracledb;" & _
"Osauthent = 1" NOTE: "Data Source =" Must Be set to the appropriate Net8 name Which is known to the name, for example, for local naming, it is the alias in the tnsnames.ora file; for oracle Names, IT is the net8 service name. For more information, see: Oracle Provider for Ole DB Developer's Guide
OLE DB Provider for Pervasive Oconn.open "provider = pervasiveoledb;" & _
"Data Source = C: / Pervasiveeb" for more information, see: Ole DB - ADO
Provider for Simple Provider OLE DB 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 Implement 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 and Q272270 To view Microsoft KB articles related to Provider for Simple Provider OLE DB, click hereOLE DB Provider for SQLBase Oconn.open "provider = SQLBaseoledb;" & _
"Data Source = mysybaseserver;" & _
"Location = mysybasedb;" & _
"User ID = myusername;" & _
"Password = MyUserpassword" for more information, see: books on-line
OLE DB Provider for SQL Server for Standard Securityoconn.open "provider = sqloledb;" & _
"Data Source = MyServerName;" & _
"Initial Catalog = MyDatabaseName;" & _
"User ID = myusername;" & _
"Password = mypassword"
For a trusted connectionoconn.open "provider = SQLOLEDB;" & _
"Data Source = MyServerName;" & _
"Initial Catalog = MyDatabaseName;" & _
Integrated Security = SSPI
To connect to a "named instance" oconn.open "provider = SQLOLEDB;" & _
"Data Source = MyServerName / MyinstanceName;" & _
"Initial Catalog = MyDatabaseName;" & _
"User ID = myusername;" & _
"Password = mypassword" Note: in Order to Connect to A SQL Server 2000 "Named Instance", You Must Have MDAC 2.6 (or Greater) Installed. To Prompt User for UserName and Passwordoconn.Provider = "SQLOLEDB"
Oconn.properties ("prompt") = adpromptalways
Oconn.open "Data Source = MyServerName;" & _
"Initial Catalog = MyDatabaseName"
To connect to SQL Server Running on the Same Computeroconn.open "provider = SQLOLEDB;" & _ "Data Source = (local);" & _
"Initial Catalog = MyDatabaseName;" & _
"User ID = myusername;" & _
"Password = mypassword"
TO Connect to SQL Server Running On A Remote Computer (Via An IP Address) Oconn.open "provider = SQLOLEDB;" & _
"NetWork Library = DBMSSOCN;" & _
"Data Source = xxx.xxx.xxx.xxx, 1433;" & _
"Initial Catalog = MyDatabaseName;" & _
"User ID = myusername;" & _
"Password = mypassword" where: - "NetWork Library = dbmsoCN" Tells ole DB to use TCP / IP Rather Than Named Pipes (Q238949) - xxx.xxx.xxx.xxx is an ip address- 1433 is the default port number for SQL . Server Q269882 and Q287932- You can also add "Encrypt = yes" for encryption for more information, see: Microsoft OLE DB Provider for SQL Server to view Microsoft KB articles related to OLE DB Provider for SQL Server, click here
OLE DB Provider for SQL Server via SQLXMLOLEDB The SQLXMLOLEDB provider is an OLE DB provider that exposes the Microsoft SQLXML functionality through ADO The SQLXMLOLEDB provider is not a rowset provider;. It can only execute commands in the "write to an output stream" mode of ADO. Oconn.open "provider = SQLXMLOLEDB.3.0;" & _
"Data provider = SQLOLEDB;" & _
"Data Source = mysqlservername;" & _
"Initial Catalog = MyDatabaseName;" & _
"User ID = myusername;" & _
"Password = myUserPassword" For more information, see: SQLXML 3.0 and A Survey of Microsoft SQL Server 2000 XML Features To view Microsoft KB articles related to SQL Server via OLE DB Provider for SQLXMLOLEDB, click hereOLE DB Provider for Sybase Adaptive Server Anywhere (ASA ) Oconn.open "provider = asaprov;" & _
"Data Source = Myasa" for more information, see: asa programming interface, guide and asa user's guide
OLE DB Provider for Sybase Adaptive Server Enterprise (ASE) Oconn.open "provider = Sybase ASE OLED DB Provider;" & _
"Data source = myaseserver" 'ooroconn.open "provider = sybase.AseoledbProvider;" & _
"SRVR = MyaseServer, 5000;" & _
"Catalog = mydbname;" & _
"User ID = myusername;" & _
"Password = myUserPassword" Where: - The Sybase ASE OLE DB provider from the Sybase 12.5 client CD - 5000 is the port number for Sybase Note:. The Open Client 12 Sybase OLE DB Provider fails to work without creating a Data Source .IDS file using the Sybase Data Administrator These .IDS files resemble ODBC DSNs Note:.. With Open Client 12.5, the server port number feature finally works, allowing fully qualified network connection strings to be used without defining any .IDS Data Source files For more information. ,: Opening Sybase Databases
.
OLE DB Provider for Unidata and Universes Oconn "provider = ardent.unioledb;" & _
"Data Source = MyServer;" & _ "location = mydatabase;" & _
"User ID = myusername;" & _
"Password = mypassword" for more information, see: IBM Using Unioledb 5.2
OLE DB Provider for Visual FoxPro Oconn.open "provider = vfpoledb;"
"Data Source = C: /VFP8/samples/data/myvfpdb.dbc;" & _
"Mode = readwrite | Share deny none;" & _
"Collating sequence = machine;" & _
"Password = ''" The Visual FoxPro OLE DB Provider is not installed by MDAC 2.x. You must install Visual FoxPro or download the OLE DB Provider For more information, see: Microsoft OLE DB Provider for Visual FoxPro To view Microsoft KB articles Related to Ole DB Provider for Visual FoxPro, Click Here.
MicrosoftMost Valuable Professional (MVP)
Questions or Comments About this Web Site, please send email to: WebmasterCopyRight © 1997 - 2005 Able Consulting, Inc. Terms of UseLast Modified: Saturday, February 19, 2005 11:53:27 PM