一聚教程网:一个值得你收藏的教程网站

热门教程

asp数据库连接代码

时间:2022-06-29 13:48:45 编辑:袖梨 来源:一聚教程网

'本文章提供一款比较完美的asp数据库连接代码哦,他不但连接access数据库同时也包括了数据库断开连接代码函数。
dim conn,rs,sql,dbpath
set conn=server.createobject("adodb.connection")
dbpath="web_data.asp"  '数据库路径
call conndate()

sub conndate()
 if err then err.clear
 on error resume next
 conn.open "provider = microsoft.jet.oledb.4.0;data source = " & server.mappath(dbpath)
 if err then
  err.clear
  set conn=nothing
  response.write "

www.111com.net提示你抱歉,数据库连接错误。
"
  response.end
 end if
end sub

sub closeconn()
    on error resume next
    if isobject(conn) then
        conn.close
        set conn = nothing
    end if
    if err then err.clear
end sub
%>

热门栏目