The following describes several ADO Connection methods: odbc dsn, odbc dsn-Less,
Ole db Provider, and "MS Remote" Provider.
1. Odbc dsn connection
I. DSN
OConn. Open "DSN = AdvWorks ;"&_
"UID = Admin ;"&_
"PWD = ;"
Note: this method cannot be used since MDAC2.1, that is, only the DSN file name is placed in ConnectString.
You must also use the DSN, UID, PWD flag. For example, the following method will cause an error in MDAC 2.1:
OConn. Open "AdvWorks"
II. File DSN
OConn. Open "FILEDSN = somepathmydb. 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 must specify the file name used in the SQL statement. For example:
ORs. Open "Select * From mermer.csv ",_
OConn, adOpenStatic, adLockReadOnly, ad1_text
B) ODBC Driver for Access
I) general security mode:
OConn. Open _
"Driver = {Microsoft Access Driver (*. mdb )};"&_
"Dbq = somepathmydb. mdb ;"&_
"Uid = Admin ;"&_
"Pwd = ;"
Ii) if System database is used:
OConn. Open _
"Driver = {Microsoft Access Driver (*. mdb )};"&_
"Dbq = somepathmydb. mdb ;"&_
"SystemDB = somepathmydb. mdw ;",_
"Admin ",""
C) ODBC Driver for SQL Server
I) general security mode
OConn. Open "Driver = {SQL Server };"&_
"Server = carl2 ;"&_
"Database = pubs ;"&_
"Uid = sa ;"&_
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service