| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1189 人关注过本帖
标题:[已解决]rs.update的奇怪问题,大家来看看,问题出在哪儿
只看楼主 加入收藏
slfyeye
Rank: 1
来 自:上海
等 级:新手上路
威 望:1
帖 子:163
专家分:0
注 册:2006-3-5
收藏
得分:0 

调用的地方是:<iframe src='admin_upload.asp?action=modify'></iframe>

amdin_upload.asp
<%
Response.expires=-1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","no-store"
%>
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="inc/UpLoadClass.asp"--> ’此处运用风声无组件上传图片
<%
If checkAdminLogin() = False Then '检验是否登录
Response.Redirect "admin_login.htm"
End If
Server.ScriptTimeOut=5000
Dim request2,rs,strSql,strAction
Set request2=New UpLoadClass '这个是风声上传里的
request2.Charset="utf-8"
request2.Open()
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upload Image</title>
<style type="text/css">body,form{margin:0;padding:0;background:#C6EBDE}#strPhoto{width:300px;}Input{font-family:"Verdana, Arial";font-size:9pt;color:#555555;background-color:#fefefe;border:1px solid #555555}</style>
</head>
<body>
<!--下面的表单用于提交图片-->
<form name="upimg" method="post" action="admin_upload.asp?toup=1" enctype="multipart/form-data"><input name="strPhoto" type="file" id="strPhoto" /> <input type="submit" name="upload" value="upload" /></form>
<%
’以下程序分为两部分,modify用于修改图片的地址(问题出在这个模块),而main则是用于添加新商品的图片
strAction = Trim(Request.QueryString("action"))
If strAction = "modify" Then
Call modify() '修改商品图片
Else Call main() '添加新商品
End If

Sub main()
If Session("imgid") = "" Then
Response.Write "<div style='background:#999999;width:300px;height:14px;font:bold 10px Verdana;color:#FFFF00;' id='noticeimg'>Only images [jpg/gif] &lt;200K are allowed!</div>"
If Request.QueryString("toup") = 1 Then
Set rs=Server.CreateObject("ADODB.Recordset")
strSql="select * from product"
rs.open strSql,G_CONN,1,3
rs.addnew
rs("imgpath")=request2.SavePath&request2.Form("strPhoto")
rs.update
'Aspjpeg组件生成两个尺寸的缩略图
Set Jpeg=Server.CreateObject("Persits.Jpeg")
Path = Server.MapPath(rs("imgpath"))
Jpeg.Open Path
Jpeg.Width = Jpeg.OriginalWidth / 2
Jpeg.Height = Jpeg.OriginalHeight / 2
Jpeg.Quality = 90
Jpeg.Save Server.MapPath("upload\middle")&Mid(rs("imgpath"),7)
Jpeg.Width = Jpeg.OriginalWidth / 2 '在上一次计算的基础上
Jpeg.Height = Jpeg.OriginalHeight / 2
Jpeg.Save Server.MapPath("upload/small")&Mid(rs("imgpath"),7)'正反斜杠都行
Set Jpeg = Nothing
Session("imgid") = rs("id") '保存上传图片对应的id
rs.Close
Set rs = Nothing
Response.Write "<script>document.upimg.style.visibility='hidden';noticeimg.innerHTML='Image uploaded.'</script>"
End If
Else
Response.Write "<script>document.upimg.style.visibility='hidden'</script><div style='background:#999999;width:300px;height:14px;font:bold 10px Verdana;color:#FFFF00;'>Image uploaded.</div></body></html>"
End If
End Sub

Sub modify()
If Session("delimg") = "" Then
Response.Write "<div style='background:#999999;width:300px;height:14px;font:bold 10px Verdana;color:#FFFF00;' id='noticeimg'>No image need to be updated!</div>"
Response.End
Else
If Request.QueryString("toup") = 1 Then
Dim rs,strSql,temp
strSql="update product set imgpath ='"&request2.SavePath&request2.Form("strPhoto")&"' where id="&Session("delimgid")
G_CONN.Execute strSql
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open "select imgpath from product where id=" & Session("delimgid"),G_CONN,1,1
temp = rs("imgpath")
Set Jpeg=Server.CreateObject("Persits.Jpeg")
Path = Server.MapPath(temp)
Jpeg.Open Path
Jpeg.Width = Jpeg.OriginalWidth / 2
Jpeg.Height = Jpeg.OriginalHeight / 2
Jpeg.Quality = 90
Jpeg.Save Server.MapPath("upload\middle")&Mid(temp,7)
Jpeg.Width = Jpeg.OriginalWidth / 2
Jpeg.Height = Jpeg.OriginalHeight / 2
Jpeg.Save Server.MapPath("upload\small")&Mid(temp,7)
Set Jpeg = Nothing
rs.Close
Set rs = Nothing
Response.Write "<script>document.upimg.style.visibility='hidden';noticeimg.innerHTML='Image uploaded.'</script>"
End If
End If
End Sub
%>

由于刚学asp不久,水平挺菜的。。所以不足之处还有很多,望高手能够多多指出不足,好让小弟改进,衷心的谢谢大家!

[此贴子已经被作者于2007-8-20 17:21:55编辑过]


2007-08-20 17:09
阳光白雪
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:39
帖 子:2220
专家分:0
注 册:2005-11-18
收藏
得分:0 
strAction = Trim(Request.QueryString("action"))
If strAction = "modify" Then
response.write("修改")
response.end()
Call modify() '修改商品图片
Else
response.write("新增")
response.end()
Call main() '添加新商品
End If

用这个试下执行了哪个动作,貌似 strAction 有问题

专注于WEB前端交互平台开发:[url=http://blog./]blog.[/url](富客户端技术(RIA)交流平台)
2007-08-20 17:17
slfyeye
Rank: 1
来 自:上海
等 级:新手上路
威 望:1
帖 子:163
专家分:0
注 册:2006-3-5
收藏
得分:0 
以下是引用阳光白雪在2007-8-20 17:17:08的发言:
strAction = Trim(Request.QueryString("action"))
If strAction = "modify" Then
response.write("修改")
response.end()
Call modify() '修改商品图片
Else
response.write("新增")
response.end()
Call main() '添加新商品
End If

用这个试下执行了哪个动作,貌似 strAction 有问题

谢谢阳光白雪,刚才试过了这一段和自己的程序,都显示的是“修改”,说明strAction是没有问题的。
继续探索中。。。。

[此贴子已经被作者于2007-8-20 17:26:33编辑过]


2007-08-20 17:24
ayue222
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:341
专家分:0
注 册:2007-7-25
收藏
得分:0 
strSql="update product set imgpath ='"&request2.SavePath&request2.Form("strPhoto")&"' where id="&Session("delimgid")
response.write strSql:response.end
G_CONN.Execute strSql

看看这个更新的时候提交的 id 和imgpath 是不是正确的 ..
2007-08-20 17:26
slfyeye
Rank: 1
来 自:上海
等 级:新手上路
威 望:1
帖 子:163
专家分:0
注 册:2006-3-5
收藏
得分:0 
谢谢大家的帮助,刚才测试下来,发现我的session("delimgid")肯定有问题,不知道我前面的哪段程序将他清空了Session("delimgid")=""。详细情况我要再好好测试一下,等问题解决后再来谢谢大家!

[此贴子已经被作者于2007-8-20 17:35:17编辑过]



2007-08-20 17:35
slfyeye
Rank: 1
来 自:上海
等 级:新手上路
威 望:1
帖 子:163
专家分:0
注 册:2006-3-5
收藏
得分:0 

已经解决,谢谢大家的帮助!昨天错误出在提交表单是漏了action=modify,导致提交后变成新增图片了。。。。看来编程需要相当细心啊。


2007-08-21 10:18
快速回复:[已解决]rs.update的奇怪问题,大家来看看,问题出在哪儿
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015896 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved