概述
分享下各种数据库的连接方式。
1.Access数据库的DSN-less连接方法:
setadocon=Server.Createobject("adodb.connection")
adoconn.Open"Driver={MicrosoftAccessDriver(*.mdb)};DBQ="&_
Server.MapPath("数据库所在路径")
2.AccessOLEDB连接方法:
setadocon=Server.Createobject("adodb.connection")
adocon.open"Provider=Microsoft.Jet.OLEDB.4.0;"&_
"DataSource="&Server.MapPath("数据库所在路径")
3.SQLserver连接方法:
setadocon=server.createobject("adodb.recordset")
adocon.Open"Driver={SQLServer};Server=(Local);UID=***;PWD=***;"&_
"database=数据库名;"
4.SQLserverOLEDB连接方法:
setadocon=Server.Createobject("adodb.connection")
adocon.open"provider=SQLOLEDB.1;DataSource=RITANT4;"&_
"userID=***;Password=***;"&_
"initalCatalog=数据库名"
5.Oracle连接方法:
setadocon=Server.Createobject("adodb.connection")
adocon.open"Driver={microsoftodbcfororacle};server=oraclesever.world;uid=admin;pwd=pass;"
6.OracleOLEDB连接方法:
setadocon=Server.Createobject("adodb.connection")
adocon.open"Provider=OraOLEDB.Oracle;datasource=dbname;userid=admin;password=pass;"
7.dBase连接方法:
setadocon=Server.Createobject("adodb.connection")
adocon.open"Driver={microsoftdbasedriver(*.dbf)};driverid=277;dbq=------------;"
8.mySQL连接方法:
setadocon=Server.Createobject("adodb.connection")
adocon.open"Driver={mysql};database=yourdatabase;
uid=username;pwd=yourpassword;option=16386;"
9.VisualFoxpro连接方法:
setadocon=Server.Createobject("adodb.connection")
adocon.open"Driver={microsoftVisualFoxprodriver};sourcetype=DBC;sourceDB=*.dbc;Exclusive=No;"
10.MStext连接方法:
setadocon=Server.Createobject("adodb.connection")
adocon.open"Driver={microsofttextdriver(*.txt;*.csv)};dbq=-----;"&_
"extensions=asc,csv,tab,txt;PersistSecurityInfo=false;"