数据库连接代码(SQL SERVER、ORACLE、ACCESS)
类别: ASP教程
首先当然是SQL server 了,现在SQL server 的市场越来越大了
<%
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"
<%
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"
- 上一篇: ASP中常用的变量命名规则
- 下一篇: 如何实现网页在线人数统计
-= 资 源 教 程 =-
文 章 搜 索