请问我这段连接数据库的代码有错误吗?为什么打不开数据库?
lianxi.asp中:
<!-- #include file="confing/add.asp" -->
<%
set rst=server.CreateObject("adodb.recordset")
if request.QueryString("act")="add" then
if trim(request.form("v_title"))="" then
msgboxU "请填写您的留言方式,方便管理员与您联系,谢谢!"
elseif trim(request.form("v_content"))="" then
msgboxU "请填写您的留言内容!"
else
sql="tbl_database"
rst.open sql,conn,1,3
rst.addnew
rst("v_title")=request.form("v_title")
rst("v_content")=request.form("v_content")
rst.update
rst.close
set myErrors=conn.errors
if myErrors.count=0 then
msgboxU "提交留言成功,请等待管理员回复!"
else
msgboxU "填写留言失败!原因:"&myErrors.item(0).description
end if
end if
end if
%>
add.asp中:
<%
dim db,conn
on error resume next
'库名及路径
db="../database/lily.mdb"
'创建库连接对象
Set conn = Server.CreateObject("ADODB.Connection")
'库连接字符串
conn.ConnectionString="driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath(db)
'建立数据库连接
conn.Open
'关闭库连接函数
%>