连接各种数据库的代码的总结

<%
function OpenConn(userid,pass,servername)
connstring="Provider=SQLOLEDB.1;Password=" & pass & ";Persist Security Info=True;User ID=" & userid
&";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 ID=" & userid & ";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"