asp数据库连接代码
<%
'(1)连接ACCESS
'**************************
Set Conn=Server.CreateObject("ADODB.Connection")
Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("*.mdb")&""
Conn.Open
'或者:
'mdbpath=server.MapPath("*.mdb")
'CnnStr = "DBQ=" & mdbpath & ";DRIVER={Microsoft Access Driver (*.mdb)};uid=用户名;pwd=密码"
'Conn.Open CnnStr
'**************************
'(2)连接SQLSERVER
'**************************
Set conn=Server.CreateObject("ADODB.Connection")
conn.Open "driver={SQLServer};server=192.168.0.1;uid=用户名;pwd=密码;database=数据库名"
'**************************
'(3)连接MYSQL
'**************************
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DSN=MYSQL5;uid=用户名;PWD=密码" '数据源名
'或者:
'Set conn=Server.CreateObject("ADODB.Connection")
'conn.Open "driver={MySQL ODBC 3.51 Driver};DATABASE=数据库名;SERVER=localhost;UID=用户名;PASSWORD=密码;PORT=3306;OPTION=3;"
'**************************
'(4)连接ORACLE
Set Conn=Server.CreateObject("ADODB.Connection")
StrConn="Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=myUsername;Pwd=myPassword;"
Conn.Open strConn
'(5)连接FOXPRO
Set Conn = Server.CreateObject( "ADODB.Connection")
Conn.Open "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=数据库路径;Exclusive=No"
%>