《2022年ado连接数据库字符串大全[归 .pdf》由会员分享,可在线阅读,更多相关《2022年ado连接数据库字符串大全[归 .pdf(19页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、ado 连接数据库字符串大全ODBC DSN CONNECTIONS.3ODBC DSN-LESS CONNECTIONS.4ODBC DRIVER FOR AS/400.4ODBC DRIVER FOR ACCESS.4ODBC DRIVER FOR DBASE.4ODBC DRIVER FOR EXCEL.5ODBC DRIVER FOR MYSQL(VIA MYODBC).5ODBC DRIVER FOR ORACLE.5ODBC DRIVER FOR PARADOX.6ODBC DRIVER FOR SQL SERVER.6ODBC DRIVER FOR SYBASE.6ODBC DR
2、IVER FOR SYBASE SQL ANYWHERE.7ODBC DRIVER FOR TERADA TA.7ODBC DRIVER FOR TEXT.7ODBC DRIVER FOR VISUAL FOXPRO.7OLE DB DATA LINK CONNECTIONS.8OLE DB PROVIDER CONNECTIONS.8OLE DB PROVIDER FOR AS/400.8OLE DB PROVIDER FOR ACTIVE DIRECTORY SERVICE.8OLE DB PROVIDER FOR DB2.9OLE DB PROVIDER FOR INDEX SERVER
3、.9OLE DB PROVIDER FOR INTERNET PUBLISHING.9OLE DB PROVIDER FOR MICROSOFT JET.9excel.10text.10OLE DB PROVIDER FOR ODBC DA TABASES.11for access(jet):.11for sql server:.11OLE DB PROVIDER FOR ORACLE(FROM MICROSOFT).11OLE DB PROVIDER FOR ORACLE(FROM ORACLE).11OLE DB PROVIDER FOR SIMPLE PROVIDER.12OLE DB
4、PROVIDER FOR SQL SERVER.12REMOTE DATA SERVICE(RDS)CONNECTIONS.13RDS DATACONTROL-CONNECT PROPERTY.13RDS DATACONTROL-URL PROPERTY.14ADO URL CONNECTIONS.14MS REMOTE PROVIDER CONNECTIONS.15名师资料总结-精品资料欢迎下载-名师精心整理-第 1 页,共 19 页 -ms remote-access(jet).15ms remote-sql server.16DATA SHAPE PROVIDER CONNECTIONS
5、.17.NET MANAGED PROVIDER CONNECTIONS.17SQL CLIENT.NET MANAGED PROVIDER.17with the sql server ole db provider(sqloledb).17ole managed provider(system.data.oledb) managed provider(system.data.odbc).18this page contains sample ado connection strings for odbc dsn/dsn-less,ole db providers,remote data se
6、rvices(rds),ms remote,ms datashape.also included are connection strings for managed provider(sqlclient,oledb,and odbc).these sample connection strings are compiled by carl prothman,a microsoft visual basic mvp.table of contents odbc dsn connections dsn,file dsn odbc dsn-less connectionsodbc driver f
7、or 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
8、 foxpro ole db data link connections data link file(udl)ole db data provider connectionsole db provider for as/400 ole db provider for active directory service ole db provider for db2 old db provider for internet publishing ole db provider for index server ole db provider for microsoft jet ole db pr
9、ovider for odbc databases ole db provider for oracle(from microsoft)名师资料总结-精品资料欢迎下载-名师精心整理-第 2 页,共 19 页 -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-ur
10、l property ado url connections ado recordset ms remote provider connections ms remote-access(jet)ms remote-sql server data shape provider connectionsms datashape-sql managed provider connections sql managed provider(system.data.sqlclient)ole managed provider(system.data.oledb) managed provider(syste
11、m.data.odbc)odbc dsn connections using 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 computers control panel(or administrative tools menu in windows 2000).make sure to create a system dsn(not a user dsn
12、)when using asp.note:you can also create the dsn via vb 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.then use the following ado connection string:odbc-file dsn oconn.open fil
13、edsn=c:somepathmydb.dsn;uid=admin;pwd=;for more information,see:about odbc data sources and how to use file dsns and dsn-less connections 名师资料总结-精品资料欢迎下载-名师精心整理-第 3 页,共 19 页 -note:the problem with dsn is that users can(and will)modify them(or delete by mistake),then your program wont work so well.so
14、 its better to use a dsn-less 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 cl
15、ient/server odbc driver for access for standard security:oconn.open driver=microsoft access driver(*.mdb);dbq=c:somepathmydb.mdb;uid=admin;pwd=;if you are using a workgroup(system database):oconn.open driver=microsoft access driver(*.mdb);dbq=c:somepathmydb.mdb;systemdb=c:somepathmydb.mdw;admin,if m
16、db is located on a network share:oconn.open driver=microsoft access driver(*.mdb);dbq=myservermysharemypathmydb.mdb;for more information,see:microsoft access driver programming considerations odbc driver for dbase oconn.open driver=microsoft dbase driver(*.dbf);driverid=277;dbq=c:somepath;名师资料总结-精品资
17、料欢迎下载-名师精心整理-第 4 页,共 19 页 -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 considerations o
18、dbc driver for excel oconn.open driver=microsoft excel driver(*.xls);driverid=790;dbq=c:somepathmyspreadsheet.xls;defaultdir=c:somepath;for more information,see:microsoft excel driver programming considerations odbc driver for mysql(via myodbc)to connect to a local database oconn.open driver=mysql;s
19、erver=myservername;option=16834;database=mydb;to connect to a remote database oconn.open driver=mysql;server=;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 drive
20、r 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;名师资料总结-精品资料欢迎下载-名师精心整
21、理-第 5 页,共 19 页 -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 engin
22、e(bde)to update paradox isam fdbf files.(q230126).for more information,see:paradox driver programming considerations 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
23、:oconn.open driver=sql server;server=myservername;database=mydatabasename;uid=;pwd=;或者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=m
24、yservername;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=inte
25、rsolv 3.10 32-bit sybase;srvr=myservername;名师资料总结-精品资料欢迎下载-名师精心整理-第 6 页,共 19 页 -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:sqlany50myd
26、b.db;uid=myusername;pwd=mypassword;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 odbc driver for teradata oconn.open provider=teradata;dbcname=mydbcname;database=mydatabasename;uid=m
27、yusername;pwd=mypassword;for more information,see teradata odbc driver odbc 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 custo
28、mer.csv,oconn,adopenstatic,adlockreadonly,adcmdtext for more information,see:text file driver programming considerations odbc driver for visual foxpro with a database container:oconn.open driver=microsoft visual foxpro driver;sourcetype=dbc;sourcedb=c:somepathmysourcedb.dbc;exclusive=no;without a da
29、tabase container(free table directory):oconn.open driver=microsoft visual foxpro driver;sourcetype=dbf;名师资料总结-精品资料欢迎下载-名师精心整理-第 7 页,共 19 页 -sourcedb=c:somepathmysourcedbfolder;exclusive=no;for more information,see:visual foxpro odbc driver and q165492 ole db data link connections data link file(udl)
30、for absolute path:oconn.open file name=c:somepathmydatabasename.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
31、in the menu list by running the c:program filescommon filessystemole dbnewudl.reg reg file,then right-click on 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 its file extension to.udl,then double-click the file.ole db pr
32、ovider 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
33、=mypassword;for more information,see:microsoft ole db provider for microsoft active 名师资料总结-精品资料欢迎下载-名师精心整理-第 8 页,共 19 页 -directory service ole db provider for db2 oconn.open=provider=db2oledb;network transport library=tcpip;network address=myserver;package collection=mypackage;host ccsid=1142 initia
34、l 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 d
35、b 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 q245359 ole db provider for micros
36、oft jet for standard security:oconn.open provider=microsoft.jet.oledb.4.0;data source=c:somepathmydb.mdb;user id=admin;password=;if using a workgroup(system database):oconn.open provider=microsoft.jet.oledb.4.0;data source=c:somepathmydb.mdb;jet oledb:system database=mysystem.mdw;admin,note,remember
37、 to convert both the mdb and the mdw to the 4.0 database format when using the 4.0 ole db provider.名师资料总结-精品资料欢迎下载-名师精心整理-第 9 页,共 19 页 -if mdb has a database password:oconn.open provider=microsoft.jet.oledb.4.0;data source=c:somepathmydb.mdb;jet oledb:database password=mydbpassword;admin,if mdb is l
38、ocated on a network share:oconn.open provider=microsoft.jet.oledb.4.0;data source=myservermysharemypathmydb.mdb;if want to open up the access database exclusively:oconn.mode=admodeshareexclusive oconn.open provider=microsoft.jet.oledb.4.0;data source=c:somepathmydb.mdb;user id=admin;password=;for mo
39、re information,see:ole db provider for microsoft jet,q191754,q225048,q239114,and q271908 excel 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:somepathmyexcelspreadsheet.xls;extended properties=excel 8.0;hdr
40、=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 the selection into the recordset.if hdr=no,then the provider will include the first row of the cell range(or named ranged)into the recordset.for more information,se
41、e:q278973 text 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 actual file ors.open select*from mytextfile.txt,oc
42、onn,adopenstatic,adlockreadonly,adcmdtext for more information,see:q262537 名师资料总结-精品资料欢迎下载-名师精心整理-第 10 页,共 19 页 -ole db provider for odbc databases for access(jet):oconn.open provider=msdasql;driver=microsoft access driver(*.mdb);dbq=c:somepathmydb.mdb;uid=myusername;pwd=mypassword;for sql server:oc
43、onn.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=m
44、ypassword;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 sou
45、rce=myoracledb;user id=/;password=;或者oconn.open provider=oraoledb.oracle;data source=myoracledb;osauthent=1;note:data source=must be set to the appropriate net8 name which is known to the naming method in use.for example,for local naming,it is the alias in the tnsnames.ora file;for oracle names,it i
46、s the net8 service name.名师资料总结-精品资料欢迎下载-名师精心整理-第 11 页,共 19 页 -for more information,see:connecting to an oracle database(note,if you get a logon dialog,then click cancel,then perform a one-time free signup with oracles technet system)ole db provider for simple provider the microsoft ole db simple pro
47、vider(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 supp
48、ort 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 connecting the osp to the msxml2.dll,therefore msxml2.dll or newer is required.oconn.open provider=msdaosp;data source=msxml
49、2.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=my
50、password;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=myservernameinst2;initial catalog=mydatabasename;user id=myusername;