Database connection string ODBC dsn,odbc dsn-less, OLE DB Provider, and "MS Remote" Provider

Source: Internet
Author: User

Tags: http io os ar using for SP file data

The following is a brief introduction to several ADO connection methods: ODBC dsn,odbc dsn-less, OLE DB Provider, and "MS Remote" Provider.

I.dsn
oConn.Open "Dsn=advworks; Uid=admin; pwd=; "
Note: It is not possible to use this method from the beginning of MDAC2.1, except that the DSN file name is placed in ConnectString. You must use the DSN,UID,PWD flag at the same time. For example, the following method will error in MDAC 2.1: oConn.Open "AdvWorks"

Ii. File DSN
oConn.Open "FILEDSN=\SOMEPATH\MYDB.DSN; Uid=admin; pwd=; "

Iii. ODBC dsn-less Connections
A) ODBC Text Driver
oConn.Open "Driver={microsoft Text Driver (*.txt; *.csv)}; dbq=\somepath\; "& _
"Extensions=asc,csv,tab,txt; Persist Security Info=false "
Note: You need to specify the file name to use in the SQL statement. For example:
oRS.Open "SELECT * from Customer.csv", oconn, adOpenStatic, adLockReadOnly, adCmdText

b) ODBC Driver for Access
i) normal safety mode:
oConn.Open "Driver={microsoft Access Driver (*.mdb)};" & _
"Dbq=\somepath\mydb.mdb; Uid=admin; pwd=; "

II) If the system database is used:
oConn.Open "Driver={microsoft Access Driver (*.mdb)};" & _
"Dbq=\somepath\mydb.mdb; systemdb=\somepath\mydb.mdw; "," admin "," "

c) ODBC Driver for SQL Server
i) normal safety mode
oConn.Open "Driver={sql Server}; Server=carl2; "& _
"Database=pubs; Uid=sa; pwd=; "

II) Use Trust Safe mode:
oConn.Open "Driver={sql Server}; Server=carl2; "& _
"Database=pubs; uid=; pwd=; "

Note: To use the blank UID and pwd

d) ODBC Driver for Oracle
i) using the existing Oracle ODBC Driver from Microsoft:
oConn.Open "Driver={microsoft ODBC for Oracle};" & _
"Server=oracleserver.world; Uid=demo; Pwd=demo; "

II) Use the old version of Oracle ODBC Driver from Microsoft:
oConn.Open "Driver={microsoft ODBC Driver for Oracle};" & _
"Connectstring=oracleserver.world; Uid=demo; Pwd=demo; "


IV) using Microsoft's OLE DB data link connections mode data link File (UDL)
A) Use absolute path
oConn.Open "File name=\somepath\pubs.udl;"

b) using relative paths
oConn.Open "File name=pubs.udl;"

V) OLE DB Provider connections mode
A) OLE DB Provider for ODBC Databases
i) Access (Jet):
oConn.Open "PROVIDER=MSDASQL; Driver={microsoft Access Driver (*.mdb)}; "& _
"Dbq=\somepath\mydb.mdb; Uid=admin; pwd=; "

II) SQL Server:
oConn.Open "PROVIDER=MSDASQL; Driver={sql Server}; "& _
"SERVER=CARL2; Database=pubs; Uid=sa; pwd=; "

b) OLE DB Provider for Microsoft Jet (Access)
i) normal safety mode:
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\somepath\mydb.mdb; User id=admin; password=; "

II) If the system database is used:
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\somepath\mydb.mdb; Jet Oledb:system database=system.mdw; "," admin "," "
Note: When using the OLE DB Provider4.0 version, you need to convert the MDB and MDW files to a 4.0 database format

III) If the MDB requires a database password:
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\somepath\mydb.mdb; Jet oledb:database Password=mydbpassword; "," admin "," "

c) OLE DB Provider for Excel Spreadsheet:
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\somepath\expenses.xls; "& _
"Extended Properties=excel 8.0; Hdr=yes; "
Note: "Hdr=yes" means the row header is in the first row, and the first row will not be included in the recordset in provider

d) OLE DB Provider for SQL Server
i) normal safety mode:
oConn.Open "PROVIDER=SQLOLEDB; Network library=dbmssocn; "& _
"Data Source=carl2; Initial catalog=pubs; User Id=sa; password=; "

II) Use Trust Safe mode:
oConn.Open "PROVIDER=SQLOLEDB; Network library=dbmssocn; "& _
"Data Source=carl2; Initial catalog=pubs; Trusted_connection=yes; "
Note: "Network LIBRARY=DBMSSOCN" declares that OLE DB uses TCP/IP instead of named Pipes.

e) OLE DB Provider for Oracle
oConn.Open "Provider=msdaora; Data Source=oracleserver.world; "& _
"User Id=sa; password=; "

(VI) Remote OLE DB Provider connections mode (RDS mode):
A) MS remote-access (Jet)
i) ODBC DSN:
oConn.Open "Remote server=http://carl2; Remote provider=msdasql; "& _
"Dsn=advworks; Uid=admin; pwd=; "

II) OLE DB Provider:
oConn.Open "Provider=ms Remote; Remote server=http://carl2; "& _
"Remote provider=microsoft.jet.oledb.4.0; Data source=\somepath\mydb.mdb; "," admin "," "

III) OLE DB provider Custom Transaction Object
oConn.Open "Provider=ms Remote; Remote server=http://carl2; "& _
"Handler=msdfmap. Handler; Data Source=myadvworksoledbconnecttag; "

b) MS Remote-sql Server
i) ODBC DSN:
oConn.Open "Remote server=http://carl2; Remote provider=msdasql; "& _
"Network LIBRARY=DBMSSOCN; Dsn=pubs; Uid=sa; pwd=; "

II) OLE DB Provider
oConn.Open "Provider=ms Remote; Remote server=http://carl2; "& _
"Remote Provider=sqloledb; Network library=dbmssocn; "& _
"Data Source=carl2; Initial catalog=pubs; User Id=sa; password=; "

Database connection string ODBC dsn,odbc dsn-less, OLE DB Provider, and "MS Remote" Provider

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: