数据库连接代码(SQLserver、Oracle、Access)

网络整理 - 09-10
首先当然是SQL server 了,现在SQL server 的市场越来越大了

<%
function OpenConn(userid,pass,servername)
connstring="Provider=SQLOLEDB.1;Password=" & pass & ";Persist Security Info=True;User;Data Source=" & servername
set conn=server.createobject("ADODB.Connection")
conn.open connstring
set OpenConn=conn
end function
%>



说到连接数据库,当然不能忘记Oracle

<%
function OpenConn(userid,pass,servername)
connstring="Provider=MSDAORA.1;Password=" & pass &";User;Persist Security Info=True"
set conn=server.createobject("ADODB.Connection")
conn.open connstring
set OpenConn=conn
end function
%>



当然还有 Access,ODBC 等等,我就只把 连接字符串放到这里,自己慢慢研究吧

connstring="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("test.mdb") &";Persist Security Info=False" //ACCESS
connstring="Provider=MSDASQL.1;Persist Security Info=False;Data Source=dsn"