最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp数据连接库代码
时间:2008-04-24 编辑:简简单单 来源:一聚教程网
这是我经常用的asp数据库连接代码,拿出来当然不是为了什么喽,只希望给初学者一些帮助,因为我记得我刚学时这个连接也搞一半天时间啊.
<%
Dim Rs,Conn//这里申明一下,必须在函数或过程外面申明,要不然会定义无效,原因是变量的全局和私有变量的原因了.
Sub Db_connect()//建立连接
Dpath ="data\db1.mdb"
Set Conn=Server.CreateObject("Adodb.connection")
Set Rs =Server.CreateObject("Adodb.Recordset")
Conn.connectionstring="Provider=Microsoft.Jet.oledb.4.0;Data source="&Server.MapPath(Dpath)
Conn.open
End sub
sub closedb()//关闭连接
if isobject(Rs) then
if not(Rs is nothing) then
Rs.close
set Rs=nothing
end if
end if
if isobject(Conn) then
if not(Conn is nothing) then
Conn.close
set Conn=nothing
end if
end if
end sub
'*********************************************************
function html_encode(html)//这里是进行基本的过滤函数,这个可以把textarea里面的回车替换成换行
dim temp
temp=replace(html,"<","<")
temp=replace(temp,">",">")
temp=replace(temp,"'","单引号")
temp=replace(temp,chr(13),"
")
html_encode=replace(temp,chr(32)," ")
end function
function encode_html(html)//这个刚好和上面个函数相反还原数据.
dim temp
temp=replace(html,"<","<")
temp=replace(temp,">",">")
temp=replace(temp,"单引号","'")
temp=replace(temp,chr(13),"
")
encode_html=replace(temp,chr(32)," ")
end function
%>
本站原创转载请注:www.111com.net
-
上一个: asp实现的代码批量修改程序
-
下一个: meditor的调用方法
相关文章
- asp 全面安全数据连接代码 06-02
- asp 高级数据连接方法 05-12
- asp数据连接代码 03-20
- asp数据连接方法 01-19
- VBS 批量Ping的项目讲解 09-19
- 如何封装一个Ajax函数介绍 09-16