高手们我都不行了,实在条不出来了,请指点!!!

yi7900 2004-04-10 09:04:47
我做的产品类型添加,编辑和删除都出错了,急呀!!!
删除时的错误:
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] 无法从指定的数据表中删除。
/products/admin/category.asp, 第 27 行
添加时的错误:
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] 操作必须使用一个可更新的查询。
/products/admin/category.asp, 第 68 行
编辑时的错误:
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] 操作必须使用一个可更新的查询。
/products/admin/category.asp, 第 100 行


我的删除,添加和编辑都在CATEGORY.ASP里,代码如下:
<%@ Language=VBScript %>
<% option explicit %>
<!--#include file="conn.asp"-->
<!--#include file="../style.asp"-->
<!--#include file="chkadmin.asp"-->
<%
dim curaction, curid,curpage, bedit, founderr, errmsg

if request("page")="" then
curpage = 1
else
curpage = cint(request("page"))
end if

curaction = request("action")
curid = request("id")
bedit = false
founderr = false
if curaction = "edit" then
bedit = true
end if

dim sql
'删除记录
if curaction = "delete" then
sql = "DELETE FROM category WHERE id=" + cstr(curid)
conn.execute sql '第27行
sql = "delete from news where cateid=" + cstr(curid)
conn.execute sql
if err.number <> 0 then
response.write "数据库操作错误:" + err.description
err.clear
else
response.write "记录已经删除。"
end if
%>
<script>
top.menu.location.reload()
</script>
<%
end if

'添加记录
if curaction = "newsave" then
if trim(request("txttitle")) = "" then
founderr = true
errmsg = "<p>请输入产品类别!</p>"
end if
if trim(request("en_txttitle")) = "" then
founderr = true
errmsg = "<p>请输入产品类别英文名称!</p>"
end if
sql="select * from category where title='" & request("txttitle") & "'"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if rs.recordcount > 0 then
founderr=true
errmsg = errmsg & "<p>该类别已经存在!</p>"
end if
rs.close
if founderr then
response.write errmsg
else
sql = "insert into category(title,en_title,class_id) values('"
sql = sql + cstr(request("txttitle")) + "','" + cstr(request("en_txttitle")) + "','" + request("class") + "')"
'response.write sql
'response.end
conn.execute sql '第68行
if err.number <> 0 then
response.write "无法保存,数据库操作出错:" + err.description
else
response.write "记录已经添加到数据库。"
end if
end if
%>
<script>
top.menu.location.reload()
</script>
<%
end if

'保存记录
if curaction = "editsave" then
if trim(request("txttitle")) = "" then
founderr = true
errmsg = "<p>请输入产品类别!</p>"
end if
if trim(request("en_txttitle")) = "" then
founderr = true
errmsg = "<p>请输入产品类别英文名称!</p>"
end if
if founderr then
response.write errmsg
else
sql = "UPDATE category SET "
sql = sql + "title='" + htmlencode(request("txttitle")) + "',"
sql = sql + "en_title='" + htmlencode(request("en_txttitle")) + "',"
sql = sql + " class_id = " + request("class")
sql = sql + " WHERE id = " + cstr(curid)
conn.execute sql '第100行
if err.number <> 0 then
response.write "无法保存,数据库操作出错:" + err.description
else
response.write "记录已经更新到数据库。"
end if
end if

end if
%>
'下面的是接着的
...全文
7 点赞 收藏 10
写回复
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
51windows 2004-04-10
Access数据库文件=》右键=》属性=》看看有没有只读,有就去掉,然后点“权限”标签=》添加everyone用户或IUSR_机器名(Internet来宾帐号)=>选定用户=》在权限中选择读权、写入!图示:http://www.51windows.net/t/mdb.gif
回复
windala716 2004-04-10
楼上的!
回复
hehaorome 2004-04-10
第68行你的CLASSID是什么类型再看看。
回复
hehaorome 2004-04-10
注意数据类型,字符串两端要加单引号,好像第一百行也是这个问题。
回复
hehaorome 2004-04-10
第27行,改为:
sql = "DELETE FROM category WHERE id='" + cstr(curid) + "'"
回复
mabro 2004-04-10
目录安全权限。修改一下权限就OK了。
代码没有问题,这种情况我遇到过。
回复
FENGUFO 2004-04-10
估计不是代码问题,参考下:
1。看看字段属性,如字符长度不够,属性错误(!导致无法保存!)
2。空间不足,或不能写磁盘(!操作必须使用一个可更新的查询。!)
3。"'"字符是否替换,access数据库中不能有日文字符,或其他非常规字符,(导致操作失败)
回复
QQgenie 2004-04-10
目录安全权限,给任何人读取\写入\修改

代码很长/好象没问题
回复
jerrycui 2004-04-10
好长,先看!
回复
yi7900 2004-04-10
<html>
<head>
<title>产品信息管理系统</title>
<meta HTTP-EQUIV="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
td { font-family: "宋体"; font-size: 9pt}
body { font-family: "宋体"; font-size: 9pt;color:ffffff}
select { font-family: "宋体"; font-size: 9pt}
A {text-decoration: none; color: #ffffff; font-family: "宋体"; font-size: 9pt}
A:hover {text-decoration: underline; color: #FF0000; font-family: "宋体"; font-size: 9pt}
-->
</style>
<script language="javascript">
function confirmDel(id,cid){
if ( confirm("你确定要删除吗?")) {
window.location.href = "category.asp?action=delete&id=" + id+"&page="+cid
}
}

</script>
</head>

<body bgcolor=#355DAA>
<%

dim rs,rs1,rs2,sql1,sql2,Class_Type,Class_Type1
set rs = server.createobject("adodb.recordset")
set rs1 = server.createobject("adodb.recordset")
set rs2 = server.createobject("adodb.recordset")
sql = "SELECT * FROM category order by id desc"
rs.open sql, conn, 1, 1
if err.number <> 0 then
response.write "数据库操作失败:"&err.description
else
if rs.eof and rs.bof then
response.write "没有记录"
else
%>

<div align="center">
<center>

<table width="100%" border="0" cellspacing="1" bgcolor="#000000">
<tr bgcolor=<%= THCOLOR %>>
<td width="70%" bgcolor="#5B83CC" colspan=2>
 == 产品二级分类 ==
</td>
<td width="30%" bgcolor="#5B83CC" align="center">操     作</td></tr>
<% dim i,j,tdcolor
j=0
rs.pagesize = 25
rs.absolutepage = curpage
for i = 1 to rs.pagesize
tdcolor = TDCOLORL
if bedit then
if clng(rs("id")) = clng(curid) then
tdcolor = TDCOLORD
end if
end if%>
<tr bgcolor=<%= tdcolor %>>
<td bgcolor="#5B83CC"> <%= rs("title") %></td>
<td bgcolor="#5B83CC"> <%= rs("en_title") %></td>
<td bgcolor="#5B83CC" align="center"><a href='category.asp?action=edit&id=<%= cstr(rs("id"))%>&page=<%=curpage%>'>编辑</a>
<a href='javascript:confirmDel(<%= rs("id")%>,<%=curpage%>)'>删除</a></td></tr>
<% rs.movenext
if rs.eof then
i = i + 1
exit for
end if
next %>
</table>
</center>
</div>
<%

response.write "<tr bgcolor=#5B83CC><td width='100%' height=15 colspan=3><center>"
response.write "第" + cstr(curpage) + "页/总" + cstr(rs.pagecount) + "页 "
response.write "本页" + cstr(i-1) + "条/总" + cstr(rs.recordcount) + "条 "
if curpage = 1 then
response.write "首页 上一页 "
else
response.write "<a href='category.asp?page=1'>首页</a> <a href='category.asp?page=" + cstr(curpage-1)+ "'>上一页</a> "
end if
if curpage = rs.pagecount then
response.write "下一页 尾页"
else
response.write "<a href='category.asp?page=" + cstr(curpage+1) + "'>下一页</a> <a href='category.asp?page=" + cstr(rs.pagecount) + "'>尾页</a>"
end if
response.write "</td></tr></tr></td></table>"
response.write "</table>"

End If
rs.close
end if


set rs = nothing
%>
<hr noshade size="1" color="#000000">
<%
if bedit then
sql1 = "SELECT * FROM category WHERE id = " + cstr(curid)
rs1.open sql1, conn, 1, 1
response.write rs1("class_id")
'response.end
sql2 = "select * from class order by class_name"
rs2.open sql2, conn, 1, 1
Class_Type=""
do while not rs2.eof
if rs2("class_id")=rs1("class_id") then
Class_Type=Class_Type & "<option value=" & rs2("class_id") & " selected >" & rs2("class_name") & "</option>"
else
Class_Type=Class_Type & "<option value=" & rs2("class_id") & ">" & rs2("class_name") & "</option>"
end if
rs2.movenext
loop
rs2.close
set rs2=nothing
else
sql2 = "select * from class order by class_name"
rs2.open sql2, conn, 1, 1
Class_Type1=""
do while not rs2.eof
Class_Type1=Class_Type1 & "<option value=" & rs2("class_id") & ">" & rs2("class_name") & "</option>"
rs2.movenext
loop
rs2.close
set rs2=nothing
end if
%>
<form action="category.asp" method="POST">
<div align="center">
<center>
<table cellspacing="1" border="0" height="26" bgcolor="#000000">
<tr>
<td width="100%" bgcolor=#5B83CC colspan="2" height="1"><p align=center><% If bedit then %>产品类别编辑:<% Else %>产品类别添加:<% End If %></p></td>
</tr>
<tr>
<td width="10%" bgcolor=#5B83CC height="23">产品一级分类:</td>
<td width="90%" bgcolor=#5B83CC height="23">
<% if bedit then %>
<select name="class" size="1">
<%=Class_Type%>
</select>
<% else %>
<select name="class" size="1">
<%=Class_Type1%>
</select>
<% end if %>
</td>
<tr>
<td width="10%" bgcolor=#5B83CC height="23">产品二级分类名称:</td>
<td width="90%" bgcolor=#5B83CC height="23"><input type="Text" name="txttitle" size="50" value='<% If bedit then
response.write rs1("title")
end if
%>'></td>
</tr>
<tr>
<td width="10%" bgcolor=#5B83CC height="23">产品二级分类英文名称:</td>
<td width="90%" bgcolor=#5B83CC height="23"><input type="Text" name="en_txttitle" size="50" value='<% If bedit then
response.write rs1("en_title")
end if
%>'></td>
</tr>
<tr><td align=center colspan="2" bgcolor=#5B83CC height="25">
<input type="Hidden" name="action" value='<% If bedit then%>editsave<% Else %>newsave<% End If %>'>
<% If bedit then %>
<input type="Hidden" name="id" value='<%= cstr(curid) %>'>
<% End If %>
<input type="Submit" name="btnsave" value="保存">
<input type="Reset" value="取消"></td></tr>
</table>

</center>
</div>

</form>

</body>
</html>


急呀,请高手指点!!!
回复
发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告