ConnectionString 모음
http://www.connectionString.com 보다 나은 듯
출처 : http://www.codemaker.co.uk/it/tips/ado_conn.htm#SQLClientManagedProvider
ADO Connection String SamplesThis page contains sample ADO connection strings for ODBC DSN / DSN-Less, OLE DB Providers, Remote Data Services (RDS), MS Remote, and MS DataShape.Also included are ADO.NET connection strings for MySQL, ODBC, OLE DB, Oracle, and SQL Server .NET Data Providers. These sample connection strings are compiled by Carl Prothman, a Microsoft ASP.NET MVP and Microsoft Certified Professional (MCP) If you have an ADO or ADO.NET connection string that is not listed below, or you see an connection string that does not have the correct setting, please send an email to Carl Prothman. Thanks! |
Table of Contents
|
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 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. You can also create the DSN via Visual Basic code. 2) Then use the following connection string - with your own DSN
oConn.Open "DSN=mySystemDSN;" & _ "Uid=myUsername;" & _ "Pwd=myPassword"
oConn.Open "FILEDSN=c:\somepath\mydb.dsn;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" For more information, see: About ODBC data sources and Note: The problem with DSN is that Users can (and will) modify or delete them by mistake, then your program won't work so well. So it's better to use a DSN-Less or OLE DB Provider connection string - with a Trusted Connection if possible!
|
ODBC DSN-Less ConnectionsFor 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;", _ "myUsername", "myPassword" If want to open up the MDB exclusively oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _ "Dbq=c:\somepath\mydb.mdb;" & _ "Exclusive=1;" & _ "Uid=admin;" & _ "Pwd=" If MDB is located on a Network Share oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _ "Dbq=\\myServer\myShare\myPath\myDb.mdb;" & _ "Uid=admin;" & _ "Pwd=" If MDB is located on a remote machine - Or use an XML Web Service via SOAP Toolkit or ASP.NET If you don't know the path to the MDB (using ASP) <% ' ASP server-side codeoConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _ "Dbq=" & Server.MapPath(".") & "\myDb.mdb;" & _ "Uid=admin;" & _ "Pwd="%> 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 don't know the path to the MDB (using VB) oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _ "Dbq=" & App.Path & "\myDb.mdb;" & _ "Uid=admin;" & _ "Pwd=" This assumes the MDB is in the same directory where the application is running. For more information, see: Microsoft Access Driver Programming Considerations To view Microsoft KB articles related to Microsoft Access Driver, click here
oConn.Open "Driver={Client Access ODBC Driver (32-bit)};" & _ "System=myAS400;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" For more information, see:
oConn.Open "Driver={Microsoft dBASE Driver (*.dbf)};" & _ "DriverID=277;" & _ "Dbq=c:\somepath" Then specify the filename in the SQL statement: 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 Considerations To view Microsoft KB articles related to Microsoft dBASE Driver, click here
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 Considerations To view Microsoft KB articles related to Microsoft Excel Driver, click here
If using INFORMIX 3.30 ODBC Driver oConn.Open "Dsn='';" & _ "Driver={INFORMIX 3.30 32 BIT};" & _ "Host=myHostname;" & _ "Server=myServerName;" & _ "Service=myServiceName;" & _ "Protocol=olsoctcp;" & _ "Database=myDbName;" & _ "UID=myUsername;" & _ "PWD=myPassword" & _' Or oConn.Open "Dsn=myDsn;" & _ "Host=myHostname;" & _ "Server=myServerName;" & _ "Service=myServiceName;" & _ "Protocol=onsoctcp;" & _ "Database=myDbName;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" If using INFORMIX-CLI 2.5 ODBC Driver oConn.Open "Driver={Informix-CLI 2.5 (32 Bit)};" & _ "Server=myServerName;" & _ "Database=myDbName;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" & _ For more information, see: Informix Developer Zone, Connection to ODBC Data Source,
For the local machine oConn.Open "Driver={Easysoft IB6 ODBC};" & _ "Server=localhost;" & _ "Database=localhost:C:\Home\Data\Mydb.gdb;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" For a remote machine oConn.Open "Driver={Easysoft IB6 ODBC};" & _ "Server=myMachineName;" & _ "Database=myMachineName:C:\Home\Data\Mydb.gdb;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" For more information, see: Connecting to InterBase and Easysoft
For the local machine oConn.Open "Driver={INTERSOLV InterBase ODBC Driver (*.gdb)};" & _ "Server=localhost;" & _ "Database=localhost:C:\Home\Data\Mydb.gdb;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" For a remote machine oConn.Open "Driver={INTERSOLV InterBase ODBC Driver (*.gdb)};" & _ "Server=myMachineName;" & _ "Database=myMachineName:C:\Home\Data\Mydb.gdb;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" For more information, see: Google Search (if you know a direct URL email me)
oConn.Open "Driver={Lotus NotesSQL 3.01 (32-bit) ODBC DRIVER (*.nsf)};" & _ "Server=myServerName;" & _ "Database=mydir\myDbName.nsf;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" & _ For more information, see: Connection keywords
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
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=OracleServer.world;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" For more information, see: Connection String Format and Attributes To view Microsoft KB articles related to Microsoft ODBC for Oracle, click here
oConn.Open "Driver={Oracle ODBC Driver};" & _ "Dbq=myDBName;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" Where: The DBQ name must be defined in the tnsnames.ora file For more information, see: Oracle8 ODBC Driver Help, Oracle ODBC FAQs, [asporacle] listserv FAQs, and ASPDB Oracle
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). Note: There is an extra space after "db" in the Paradox Driver name For more information, see: Paradox Driver Programming Considerations To view Microsoft KB articles related to Microsoft Paradox Driver, click here
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") = adPromptAlwaysoConn.Open "Driver={SQL Server};" & _ "Server=MyServerName;" & _ "DataBase=myDatabaseName" To connect to SQL Server running on the same computer oConn.Open "Driver={SQL Server};" & _ "Server=(local);" & _ "Database=myDatabaseName;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" To connect to SQL Server running on a remote computer (via an IP address) oConn.Open "Driver={SQL Server};" & _ "Server=xxx.xxx.xxx.xxx;" & _ "Address=xxx.xxx.xxx.xxx,1433;" & _ "Network=DBMSSOCN;" & _ "Database=myDatabaseName;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" Where: For more information, see: SQLDriverConnect (ODBC) To view Microsoft KB articles related to ODBC Driver for SQL Server, click here
If using the Sybase System 12 (or 12.5) Enterprise Open Client ODBC Driver oConn.Open "Driver={SYBASE ASE ODBC Driver};" & _ "Srvr=myServerName;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" 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 To view Microsoft KB articles related to ODBC Driver for Sybase, click here
oConn.Open "ODBC; Driver=Sybase SQL Anywhere 5.0;" & _ "DefaultDir=c:\dbpath\;" & _ "Dbf=c:\sqlany50\mydb.db;" & _ "Uid=myUsername;" & _ "Pwd=myPassword;" & _ "Dsn=""""" Note: Including the DSN tag with a null string is absolutely critical or else you get the dreaded -7778 error. For more information, see: Sybase SQL Anywhere User Guide
oConn.Open "Provider=Teradata;" & _ "DBCName=MyDbcName;" & _ "Database=MyDatabaseName;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" For more information, see Teradata ODBC Driver
oConn.Open _ "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _ "Dbq=c:\somepath\;" & _ "Extensions=asc,csv,tab,txt" Then specify the filename in the SQL statement: oRs.Open "Select * From customer.csv", _ oConn, adOpenStatic, adLockReadOnly, adCmdText Note: If you are using a Tab delimited file, then make sure you create a schema.ini file, and include the "Format=TabDelimited" option. For more information, see: Text File Driver Programming Considerations To view Microsoft KB articles related to Microsoft Text Driver, click here
With a database container oConn.Open "Driver={Microsoft Visual FoxPro Driver};" & _ "SourceType=DBC;" & _ "SourceDB=c:\somepath\mySourceDb.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 To view Microsoft KB articles related to ODBC Driver for Visual FoxPro, click here
|
OLE DB Data Link Connections
For Absolute Path oConn.Open "File Name=c:\somepath\myDatabaseName.udl" 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 on the desktop and select "New | Microsoft Data 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
|
OLE DB Provider ConnectionsoConn.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
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)
oConn.Open "Provider=IBMDA400;" & _ "Data source=myAS400;" & _ "User Id=myUsername;" & _ "Password=myPassword" For more information, see:
oConn.Open "Provider=SNAOLEDB;" & _ "Data source=myAS400;" & _ "User Id=myUsername;" & _ "Password=myPassword" For more information, see: Connection and ConnectionString Property To view Microsoft KB articles related to OLE DB Provider for AS/400 and VSAM, click here
For Data Warehouse oConn.Open "Provider=Commerce.DSO.1;" & _ "Data Source=mscop://InProcConn/Server=mySrvName:" & _ "Catalog=DWSchema:Database=myDBname:" & _ "User=myUsername:Password=myPassword:" & _ "FastLoad=True" ' OroConn.Open "URL=mscop://InProcConn/Server=myServerName:" & _ "Database=myDBname:Catalog=DWSchema:" & _ "User=myUsername:Password=myPassword:" & _ "FastLoad=True" For Profiling System oConn.Open "Provider=Commerce.DSO.1;" & _ "Data Source=mscop://InProcConn/Server=mySrvName:" & _ "Catalog=Profile Definitions:Database=myDBname:" & _ "User=myUsername:Password=myPassword" ' OroConn.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
For TCP/IP connections oConn.Open = "Provider=DB2OLEDB;" & _ "Network Transport Library=TCPIP;" & _ "Network Address=xxx.xxx.xxx.xxx;" & _ "Initial Catalog=MyCatalog;" & _ "Package Collection=MyPackageCollection;" & _ "Default Schema=MySchema;" & _ "User ID=MyUsername;" & _ "Password=MyPassword" For APPC connections oConn.Open = "Provider=DB2OLEDB;" & _ "APPC Local LU Alias=MyLocalLUAlias;" & _ "APPC Remote LU Alias=MyRemoteLUAlias;" & _ "Initial Catalog=MyCatalog;" & _ "Package Collection=MyPackageCollection;" & _ "Default Schema=MySchema;" & _ "User ID=MyUsername;" & _ "Password=MyPassword" For more information, see: Connection, ConnectionString Property, and Q218590 To view Microsoft KB articles related to OLE DB Provider for DB2, click here
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
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
Actually there is no OLE DB Provider for Excel. However, you can use the OLE DB Provider for JET to read and write data in Microsoft Excel workbooks. Or you can use the ODBC Driver for Excel.
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
oConn.Open "Provider=MSDAIPP.DSO;" & _ "Data Source=http://mywebsite/myDir;" & _ "User Id=myUsername;" & _ "Password=myPassword" ' Or oConn.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
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", _ "myUsername", "myPassword" Note, remember to convert both the MDB and the MDW to the 4.0 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", _ "myUsername", "myPassword" If want to open up the MDB exclusively oConn.Mode = adModeShareExclusiveoConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=c:\somepath\myDb.mdb;" & _ "User Id=admin;" & _ "Password=" If MDB is located on a network share oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=\\myServer\myShare\myPath\myDb.mdb" If MDB is located on a remote machine |