注册 登录
编程论坛 ASP技术论坛

[求助]更新不到数据库啊 ?

fuhuijun 发布于 2007-11-18 14:03, 394 次点击

<!--#include virtual ="./conn.asp"-->
<%dim sql,id,cate,title,content
id =Trim(request.Form("id")
response.Write(id)
cate =Trim(request.Form("cate")
title =Trim(request.Form("title")
content =Trim(request.Form("content")
sql = "update news set Type_id='"&cate&"',Title='"&title&"',Content='"&content&"'where id="&id
set rs=server.CreateObject("ADODB.recordset")
rs.open sql,conn,1,1
rs.close
set rs=nothing
%>

9 回复
#2
fuhuijun2007-11-18 14:04

id输出不了啊 ?

#3
fuhuijun2007-11-18 14:08



<!--#include virtual ="./conn.asp"-->
<%dim id,sql
id = Cint(request.form("id"))
sql="select * from news where id ='"&id&"'"
set rs=server.CreateObject("ADODB.recordset")
rs.open sql,conn,1,1

%>
<%

dim sql2

set rs2 = server.CreateObject("adodb.recordset")
sql2 ="select * from nType "

rs2.open sql2,conn,1,1


%>

<table width="84%" height="185" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#00FF66">

<form action="xiugai_success.asp" name="form" method="post">

<input type="hidden" name="id" value="<%=rs.fields("id")%>">
<tr>
<td width="21%" align="center" bgcolor="#FFFFFF">新闻类别:</td>
<td width="44%" bgcolor="#FFFFFF">


<select name="cate">

<%
while not rs2.eof

%>
<option value="<%=rs2("tid")%>" <%if rs2("tid")=id then%> selected <%end if%>><%=rs2("ntype")%></option>

<%
rs2.movenext
wend

%>

<%rs2.close

set rs2=nothing

%>
</select>


</td>
<td width="35%" bgcolor="#FFFFFF">*必须填写</td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">新闻标题:</td>

<td bgcolor="#FFFFFF"><input type="text" name="title" value="<%=rs.fields("Title")%>">
<td bgcolor="#FFFFFF">*新闻标题不能为空</td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">新闻内容:</td>
<td bgcolor="#FFFFFF"><textarea name="content" rows="10" cols="50"><%=rs.fields("Content")%></textarea></td>
<td bgcolor="#FFFFFF">*新闻内容不能为空!</td>
</tr>


<tr>
<td colspan="3" bgcolor="#FFFFFF"><center><input name="sub" type="submit" value="修改新闻"></center></td>



</tr>

</form>
</table>


#4
fuhuijun2007-11-18 14:12
在和大家说一下就是数据传递不过来?
到底是什么原因了
谢谢
#5
purana2007-11-18 14:14
response.write Cint(request.form("id"))
这样输出不了?.
#6
fuhuijun2007-11-18 14:26

sql="update news set Type_id='"&cate&"',Title='"&title&"',Content='"&content&"' where id="&id
rs.open sql,conn,1,1
麻烦大家在帮我看一下是不是我的更新语句有问题啊?
怎么一提交就不显示了呢
谢谢
#7
fuhuijun2007-11-18 14:27
现在可以输出了
#8
fuhuijun2007-11-18 14:29
谢谢
#9
hmhz2007-11-18 14:31
更新数据不可以这样写
sql="update news set Type_id='"&cate&"',Title='"&title&"',Content='"&content&"' where id="&id
rs.open sql,conn,1,1

改成这样
conn.execute "update news set Type_id='"&cate&"',Title='"&title&"',Content='"&content&"' where id="&id
#10
kira0072007-11-18 16:05
有更新,删除操作的程式应该不用“conn,1,1”而是“conn,1,3”
1