弄了套asp程序添加和删除都没问题,修改的时候提示成功但记录没变化,请帮看下代码那里有问题,谢谢!!
<%ifsession("flag")=1then%><!--#includefile="topcommon.asp"--><%else%><!--#includefil...
<%if session("flag")=1 then%>
<!--#include file="topcommon.asp"-->
<%else%>
<!--#include file="top.asp"-->
<!--#include file="conn.asp"-->
<%end if%>
<%
id=request.querystring("id")
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "Select * From zjxx where zjid="&id,conn,1,3
%>
<form method="post" action="modifysave.asp">
出问题相关表单如下:
<td align="left" height="15" width="9%">设备类型: </td>
<td align="left" height="15" width="32%"> <font size="2">
<select class="unnamed2" name="txttypeid" size="1">
<% dim rstype,sqltype
if session("flag")=1 then
sqltype="select * from type"
end if
if session("flag")=2 then
sqltype="select * from type where danwei='"&session("danwei")&"'"
end if
if session("flag")=3 then
sqltype="select * from type where manager='"&session("xingming")&"'"
end if
set rstype=server.createobject("adodb.recordset")
rstype.open sqltype,conn,1,1
do while not rstype.eof
response.write "<option "&" value='"+CStr(rstype("typeid"))+"' name=typeid>"+rstype("type")+"</option>"+chr(13)+chr(10)
rstype.movenext
loop
rstype.close
set rstype=nothing
%>
</select>
</font></td>
以下是modifysave.asp
<%
if session("admin")="" then
response.redirect "admin.asp"
end if
%>
<html>
<body>
<%
ip=request("txtip")
wgzw=request("txtwgzw")
sbmc=request("txtsbmc")
sbbm=request("txtsbbm")
ssdw=request("txtowner")
sbwz=request("txtsbwz")
jbpz=request("txtjbpz")
else1=request("txtelse")
system=request("txtsystem")
yyms=request("txtyyms")
buytime=request("txtbuytime")
zrr=request("txtzrr")
lxdh=request("txtlxdh")
yxzt=request("txtyxzt")
typeid=request("txttypeid")
ltzy=request("txtltzy")
whbz=request("txtwhbz")
sqltype="select * from type where typeid="&typeid
set rstype=server.createobject("adodb.recordset")
rstype.open sqltype,conn,1,1
type1=request("type")
set rs=server.createobject("adodb.recordset")
sql="select * from zjxx where zjid="&id
rs.open sql,conn,1,3
rs("ip")=ip
rs("wgzw")=wgzw
rs("sbmc")=sbmc
rs("sbbm")=sbbm
rs("ssdw")=ssdw
rs("sbwz")=sbwz
rs("jbpz")=jbpz
rs("else")=else1
rs("system")=system
rs("yyms")=yyms
rs("buytime")=buytime
rs("zrr")=zrr
rs("lxdh")=lxdh
rs("yxzt")=yxzt
rs("typeid")=typeid
rs("type")=type1
rs("ltzy")=ltzy
rs("whbz")=whbz
rs.update
response.write err.ascription '打印sql语句出错信息
rstype.close
set rstype=nothing
rs.close
set rs=nothing
conn.close
set conn=nothing
%> 展开
<!--#include file="topcommon.asp"-->
<%else%>
<!--#include file="top.asp"-->
<!--#include file="conn.asp"-->
<%end if%>
<%
id=request.querystring("id")
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "Select * From zjxx where zjid="&id,conn,1,3
%>
<form method="post" action="modifysave.asp">
出问题相关表单如下:
<td align="left" height="15" width="9%">设备类型: </td>
<td align="left" height="15" width="32%"> <font size="2">
<select class="unnamed2" name="txttypeid" size="1">
<% dim rstype,sqltype
if session("flag")=1 then
sqltype="select * from type"
end if
if session("flag")=2 then
sqltype="select * from type where danwei='"&session("danwei")&"'"
end if
if session("flag")=3 then
sqltype="select * from type where manager='"&session("xingming")&"'"
end if
set rstype=server.createobject("adodb.recordset")
rstype.open sqltype,conn,1,1
do while not rstype.eof
response.write "<option "&" value='"+CStr(rstype("typeid"))+"' name=typeid>"+rstype("type")+"</option>"+chr(13)+chr(10)
rstype.movenext
loop
rstype.close
set rstype=nothing
%>
</select>
</font></td>
以下是modifysave.asp
<%
if session("admin")="" then
response.redirect "admin.asp"
end if
%>
<html>
<body>
<%
ip=request("txtip")
wgzw=request("txtwgzw")
sbmc=request("txtsbmc")
sbbm=request("txtsbbm")
ssdw=request("txtowner")
sbwz=request("txtsbwz")
jbpz=request("txtjbpz")
else1=request("txtelse")
system=request("txtsystem")
yyms=request("txtyyms")
buytime=request("txtbuytime")
zrr=request("txtzrr")
lxdh=request("txtlxdh")
yxzt=request("txtyxzt")
typeid=request("txttypeid")
ltzy=request("txtltzy")
whbz=request("txtwhbz")
sqltype="select * from type where typeid="&typeid
set rstype=server.createobject("adodb.recordset")
rstype.open sqltype,conn,1,1
type1=request("type")
set rs=server.createobject("adodb.recordset")
sql="select * from zjxx where zjid="&id
rs.open sql,conn,1,3
rs("ip")=ip
rs("wgzw")=wgzw
rs("sbmc")=sbmc
rs("sbbm")=sbbm
rs("ssdw")=ssdw
rs("sbwz")=sbwz
rs("jbpz")=jbpz
rs("else")=else1
rs("system")=system
rs("yyms")=yyms
rs("buytime")=buytime
rs("zrr")=zrr
rs("lxdh")=lxdh
rs("yxzt")=yxzt
rs("typeid")=typeid
rs("type")=type1
rs("ltzy")=ltzy
rs("whbz")=whbz
rs.update
response.write err.ascription '打印sql语句出错信息
rstype.close
set rstype=nothing
rs.close
set rs=nothing
conn.close
set conn=nothing
%> 展开
展开全部
'如果程序出错,应该是modifysave.asp出错,没有看到包入数据库链接页<!--#include file="conn.asp"--> ,是复制时省略了呢还是本来没有,不得而知。
'本页代码,帮整理了一下,请注意我打了标记的地方,修改后复制下面代码执行,如果还是不能完成更新,请检查是否是SQL查询语句中有没有字段名错误。
以下是modifysave.asp
<%
if session("admin")="" then
response.redirect "admin.asp"
end if
%>
<html>
<body>
<%
'要习惯先声明局部变量:
dim ip,wgzw,sbmc,sbbm,ssdw,sbwz,jbpz,else1,system,yyms,buytime,zrr,lxdh,yxzt,typeid,ltzy,whbz
dim sqltype,rs
ip=request("txtip")
wgzw=request("txtwgzw")
sbmc=request("txtsbmc")
sbbm=request("txtsbbm")
ssdw=request("txtowner")
sbwz=request("txtsbwz")
jbpz=request("txtjbpz")
else1=request("txtelse")
system=request("txtsystem")
yyms=request("txtyyms")
buytime=request("txtbuytime")
zrr=request("txtzrr")
lxdh=request("txtlxdh")
yxzt=request("txtyxzt")
typeid=int(request("txttypeid"))
ltzy=request("txtltzy")
whbz=request("txtwhbz")
'sqltype="select * from type where typeid="&typeid
'set rstype=server.createobject("adodb.recordset")
'rstype.open sqltype,conn,1,1
'type1=request("type") '请注意此行:type1=request("type") 是不是写错了?应是type1=rstype("type") 吧?否则你select type表干嘛?
'下面是修改过的代码:
Set rstype = Conn.Execute("select * from type where typeid="&typeid )
If Not(rstype.bof and rstype.eof) Then type1=rstype("type")
rstype.close:set rstype=nothing
set rs=server.createobject("adodb.recordset")
sql="select * from zjxx where zjid="&id '注意此行:变量id从哪里来的?没看出来,如果id值为空,程序就不能更新
rs.open sql,conn,1,3
rs("ip")=ip
rs("wgzw")=wgzw
rs("sbmc")=sbmc
rs("sbbm")=sbbm
rs("ssdw")=ssdw
rs("sbwz")=sbwz
rs("jbpz")=jbpz
rs("else")=else1
rs("system")=system
rs("yyms")=yyms
rs("buytime")=buytime
rs("zrr")=zrr
rs("lxdh")=lxdh
rs("yxzt")=yxzt
rs("typeid")=typeid
rs("type")=type1
rs("ltzy")=ltzy
rs("whbz")=whbz
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
'本页代码,帮整理了一下,请注意我打了标记的地方,修改后复制下面代码执行,如果还是不能完成更新,请检查是否是SQL查询语句中有没有字段名错误。
以下是modifysave.asp
<%
if session("admin")="" then
response.redirect "admin.asp"
end if
%>
<html>
<body>
<%
'要习惯先声明局部变量:
dim ip,wgzw,sbmc,sbbm,ssdw,sbwz,jbpz,else1,system,yyms,buytime,zrr,lxdh,yxzt,typeid,ltzy,whbz
dim sqltype,rs
ip=request("txtip")
wgzw=request("txtwgzw")
sbmc=request("txtsbmc")
sbbm=request("txtsbbm")
ssdw=request("txtowner")
sbwz=request("txtsbwz")
jbpz=request("txtjbpz")
else1=request("txtelse")
system=request("txtsystem")
yyms=request("txtyyms")
buytime=request("txtbuytime")
zrr=request("txtzrr")
lxdh=request("txtlxdh")
yxzt=request("txtyxzt")
typeid=int(request("txttypeid"))
ltzy=request("txtltzy")
whbz=request("txtwhbz")
'sqltype="select * from type where typeid="&typeid
'set rstype=server.createobject("adodb.recordset")
'rstype.open sqltype,conn,1,1
'type1=request("type") '请注意此行:type1=request("type") 是不是写错了?应是type1=rstype("type") 吧?否则你select type表干嘛?
'下面是修改过的代码:
Set rstype = Conn.Execute("select * from type where typeid="&typeid )
If Not(rstype.bof and rstype.eof) Then type1=rstype("type")
rstype.close:set rstype=nothing
set rs=server.createobject("adodb.recordset")
sql="select * from zjxx where zjid="&id '注意此行:变量id从哪里来的?没看出来,如果id值为空,程序就不能更新
rs.open sql,conn,1,3
rs("ip")=ip
rs("wgzw")=wgzw
rs("sbmc")=sbmc
rs("sbbm")=sbbm
rs("ssdw")=ssdw
rs("sbwz")=sbwz
rs("jbpz")=jbpz
rs("else")=else1
rs("system")=system
rs("yyms")=yyms
rs("buytime")=buytime
rs("zrr")=zrr
rs("lxdh")=lxdh
rs("yxzt")=yxzt
rs("typeid")=typeid
rs("type")=type1
rs("ltzy")=ltzy
rs("whbz")=whbz
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询