请问我这段连接数据库的代码有错误吗?为什么打不开数据库?

Marrylily 2008-07-21 12:25:57
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

'关闭库连接函数

%>
...全文
44 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Linzhe423 2008-07-21
  • 打赏
  • 举报
回复
conn.connectionstring="provider=microsoft.jet.oledb.4.0;data source="&server.MapPath("../database/lily.mdb")
atmo 2008-07-21
  • 打赏
  • 举报
回复
错误提示贴出来
rankisky 2008-07-21
  • 打赏
  • 举报
回复
conn

报缺少对象吗?
sy_binbin 2008-07-21
  • 打赏
  • 举报
回复
on error resume next 去掉

错误提示贴出来

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧