为什么我的asp后台中不能写进数据库!各位高手帮帮我啊!谢了啊!源码如下!

时光如水 2008-05-23 10:54:54
<!--#include file="conn.asp"-->
<!--#include file="admin.asp"-->
<%if Request.QueryString("mark")="southidc" then
id=request("id")
dj_name=Trim(Request("dj_name"))
djcatid=Trim(Request("djcatid"))
desc=Trim(Request("desc"))
pic=Trim(Request("pic"))
url=Trim(Request("url"))

Set rs_news = Server.CreateObject("ADODB.Recordset")
sql="select * from dj where dj_id="&id
rs_news.open sql,conn,1,3
rs_news("dj_name")=dj_name
rs_news("djcat_id")=djcatid
rs_news("dj_desc")=desc
rs_news("dj_pic")=pic
rs_news("dj_url")=url
rs_news("dj_date")=Date()
rs_news.update
rs_news.close
response.redirect "Admin_Honor.asp"
end if
%>
<SCRIPT language=javascript src="zyok.JS"></SCRIPT>
<%
id=request.querystring("id")
Set rs_news = Server.CreateObject("ADODB.Recordset")
rs_news.Open "Select * From dj where dj_id="&id, conn,1,1
%>
<!-- #include file="Inc/Head.asp" -->
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top"><table width="780" border="0" cellpadding="2" cellspacing="1" class="table_southidc">
<tr>
<td class="back_southidc" height="25"> <div align="center"><strong>修改 <br>
</strong></div></td>
</tr>
<tr>
<form method="post" name="myform" action="Admin_HonorEdit.asp?mark=southidc">
<input type=hidden name=id value=<%=id%>>
<td><div align="center">
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr bgcolor="#ECF5FF">
<td width="10%" height="25">
<div align="center">影音名称</div></td>
<td>  
<input name="name" type="text" id="name" size="40" value="<%=rs_news("dj_name")%>"></td>
</tr>
<tr bgcolor="#ECF5FF">
<td width="10%" height="25">
<div align="center">影音分类</div></td>
<td>  
<select name="djcatid" id="djcatid">
<%
sql="select * from djcat"
set rs2=server.createobject("adodb.recordset")
rs2.open sql,conn,1,1
do while not rs2.eof%>
<option value="<%=rs2("djcat_id")%>" <%if rs2("djcat_id")=rs("djcat_id") then response.write "selected" end if%>><%=rs2("djcat_name")%></option>
<%rs2.movenext
loop
if rs2.eof and rs2.bof then%>
<option value="0">当前没有影音分类</option>
<%end if%>
</select>

<select name="pic">
<option value="asf" <%if rs("dj_pic")="asf" then response.write "selected" end if%>>ASF音乐</option>
<option value="asfmtv" <%if rs("dj_pic")="asfmtv" then response.write "selected" end if%>>ASF影视</option>
<option value="rm" <%if rs("dj_pic")="rm" then response.write "selected" end if%>>RAM音乐</option>
<option value="rmmtv" <%if rs("dj_pic")="rmmtv" then response.write "selected" end if%>>RAM影视</option>
<option value="flash" <%if rs("dj_pic")="flash" then response.write "selected" end if%>>FLASH动画</option>

</select>
<select name="desc">
<option value="☆☆★★★">推荐等级</option>
<option value="☆☆☆☆★">☆☆☆☆★</option>
<option value="☆☆☆★★">☆☆☆★★</option>
<option value="☆☆★★★" selected>☆☆★★★</option>
<option value="☆★★★★">☆★★★★</option>
<option value="★★★★★">★★★★★</option>
</select>

<%
ranNum=int(9*rnd)+10
iddata=month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
%></td>
</tr>
<tr bgcolor="#ECF5FF">
<td width="10%" height="25">
<div align="center">url地址</div></td>
<td>  
<input name="url" type="text" id="url" size="60" value="<%=rs_news("dj_url")%>"></td>
</tr>
<tr bgcolor="#ECF5FF">
<td height="22"> </td>
<td colspan="2"> </td>
</tr>
<tr bgcolor="#ECF5FF">
<td height="25" colspan="2">
<div align="center">
<input name="submit" type="submit" value="确定">
 
<input name="reset" type="reset" value="从来">
</div></td>
</tr>
</table>
</div></td>
</form>
</tr>
</table></td>
</tr>
</table>
<!-- #include file="Inc/Foot.asp" -->
...全文
81 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
rankisky 2008-05-23
  • 打赏
  • 举报
回复
if Request.QueryString("mark")="southidc" then
…………………………
…………………………
else
response.write "mark没值"
end if
ljie520net 2008-05-23
  • 打赏
  • 举报
回复
输出 Request.QueryString("mark") 的值 看看
时光如水 2008-05-23
  • 打赏
  • 举报
回复
谢谢这些很好心的朋友!
我觉得这些csdn的网友都非常的热情,比在百度上问问题快多了

我是一个出来csdn的做网页设计的!
的确大家的热情让我喜欢上了csdn!!!谢谢了了啊!
sonicryu 2008-05-23
  • 打赏
  • 举报
回复
如果是添加记录的话 一定要用 addnew 见3楼

如果是更新的话

给你个思路,逐步缩小错误范围

先用

Set rs_news = Server.CreateObject("ADODB.Recordset")
sql="select * from dj where dj_id="&id
rs_news.open sql,conn,1,3
rs_news("dj_name")=111
rs_news("djcat_id")=111
rs_news("dj_desc")=111
rs_news("dj_pic")=111
rs_news("dj_url")=111
rs_news.update
rs_news.close

写数据库,看看记录进去了没有


如果可以 说明是上面的if 或 变量了问题

如果还是不行就是连数据没设置好 或 表名不对

友情支持 楼主加油



hancheng 2008-05-23
  • 打赏
  • 举报
回复
为什么不用
sql="insert tabless (a) values ('a')"
conn.execute sql

这更简单直观,就算以后到php/jsp都很容易理解。

另外看一下你databse所在目录有没有开放权限,本机把everyone也给全部权限
xiaoyi1234 2008-05-23
  • 打赏
  • 举报
回复
Set rs_news = Server.CreateObject("ADODB.Recordset")
sql="select * from dj where dj_id="&id
rs_news.open sql,conn,1,3
rs_news.addnew
rs_news("dj_name")=dj_name
rs_news("djcat_id")=djcatid
rs_news("dj_desc")=desc
rs_news("dj_pic")=pic
rs_news("dj_url")=url
rs_news("dj_date")=Date()
rs_news.update
rs_news.close
response.redirect "Admin_Honor.asp"
end if

这20 也是我的 哈哈

28,404

社区成员

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

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