| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 871 人关注过本帖
标题:刚学的ASP,怎样将<%=rs("title")%>传递来的title写进数据库? ...
只看楼主 加入收藏
xiaoturn
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2010-6-9
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:2 
刚学的ASP,怎样将<%=rs("title")%>传递来的title写进数据库?

<%
ShowSmallClassType=ShowSmallClassType_Article
dim ID
ID=trim(request("ID"))
if ID="" then
    response.Redirect("Product.asp")
end if

sql="select * from Product where ID=" & ID & ""
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,3
if rs.bof and rs.eof then
    response.write"<SCRIPT language=JavaScript>alert('找不到此产品!');"
  response.write"javascript:history.go(-1)</SCRIPT>"
else   
    rs("Hits")=rs("Hits")+1
    rs.update
%>

这个是form到添加数据到数据库的文件,重点是要把产品名跟产品价格写进数据库,其他的数据都已经能写进数据库了。请大侠帮我看看。红色两句代码不知道是不是错误所在。

<form action="ordersave.asp" method="post" name="form1" id="form1">
                          <table width="100%" border="0" cellspacing="0" cellpadding="0"  class=iframebg>
                            <tr>
                              <td><br><IMG src="index_files/form_22.gif"></td>
                            </tr>
                          </table>
                          <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                            <tr>
                              <td width="90%"> <div align="center">
                                  <table width="90%" height="409"border="0" align="center" cellspacing="3" class=line_dinggou>
                            <tr>
                            <td width="100%" colspan="2" align="center">
                            <table width="80%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="24%" height="39"><div align="right">产品名:</div></td>
    <td width="41%" height="40"><SPAN class=price style="FONT-SIZE: 14px"><%=rs("title")%></SPAN></td>
<td width="20%" height="39" align="right"><SPAN class=price style="FONT-SIZE: 14px">产品价格:</SPAN></td>
    <td width="41%" height="40"><SPAN class=price style="FONT-SIZE: 14px"><%=rs("Price")%>元</SPAN></td>
  </tr>
</table>                            </td>
                          </tr>
                                    <tr>
                                                               
                                      <td height="25" align="right"><font color="#FF0000">*</font>订购数量: </td>
                                      <td height="25"><input type="text" name="shuliang" size="5" maxlength="36" style="font-size: 14px" >
                                        台</td>
                                    </tr>
                                    <tr>
                                      <td height="25" align="right"><font color="#FF0000">*</font> 订购人姓名:</td>
                                      <td width="77%" height="-2"><font>
                                      <input name="Receiver" type="text" id="Receiver" style="font-size: 14px">
                                        </font></td>
                                    </tr>
                                   <!-- <tr>
                                      <td width="23%" height="25" align="right"><font color="#FF0000">*</font>公司名称:</td>
                                      <td width="77%" height="-6"><font>
                                        <input type="text" name="CompanyName" size="30" maxlength="36" value="<%=rs("CompanyName")%>" style="font-size: 14px" >
                                        </font></td>
                                    </tr> -->
                                    <tr>
                                      <td height="25" align="right"><font color="#FF0000">*</font>详细地址:</td>
                                      <td height="-2"><font>
                                        <input name="Add" type="text"  id="Add" style="font-size: 14px" size="40" maxlength="60">
                                        </font><font color="#FF0000">格式:省-市-区-路名-办公地名(小区名)-几单元几号,请尽量详细填写</font> </td>
                                    </tr>
                                    <tr>
                                      <td height="25" align="right"><font color="#FF0000">*</font>邮编:</td>
                                      <td height="-2"><font>
                                        <input name="Postcode" type="text"  id="Postcode" style="font-size: 14px"  size="12" maxlength="6">
                                        </font></td>
                                    </tr>
                                   <!-- <tr>
                                      <td height="25" align="right">联系人:</td>
                                      <td width="77%" height="-2"><font>
                                        <input type="text" name="Receiver" size="12" maxlength="30" value="<%=rs("Receiver")%>" style="font-size: 14px" >
                                        </font> * </td>
                                    </tr> -->
                                    <tr>
                                      <td height="25" align="right">固定电话:</td>
                                      <td width="77%" height="-1"><font>
                                        <input type="text" name="Phone" size="24" maxlength="36" style="font-size: 14px" >
                                        </font>(固定电话为选填项)</td>
                                    </tr>
                                    <tr>
                                      <td height="25" align="right"><font color="#FF0000">*</font>移动电话:</td>
                                      <td height="11"><font>
                                        <input name="Mobile" type="text" id="Mobile" style="font-size: 14px" size="24" maxlength="36">
                                        </font></td>
                                    </tr>
                                    <tr>
                                      <td height="25" align="right"><font color="#FF0000">*</font>支付方式:</td>
                                      <td width="77%" height="11">&nbsp;</td>
                                    </tr>
                                    <tr>
                                      <td height="25" align="right">&nbsp;</td>
                                      <td height="11"><label>
                                        <input name="PayType" type="radio" value="货到付款" checked>
                                      货到付款   
                                      <input type="radio" name="PayType" value="网上支付">
网银支付(<font color="#FF0000">网银支付更可享受95折优惠!</font>)<A
  href="http://pay3. target=_blank><IMG
  style="BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none"
  src="index_files/bank.gif"></A> </label></td>
                                    </tr>
                                    <tr>
                                      <td height="25" align="right" valign="top"><font color="#FF0000">*</font>送货时间:</td>
                                      <td width="77%" height="11"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                          <td><label>
                                            <input name="songhuoshijian" type="radio" value="工作日、双休日与节假日均可送货" checked>
                                          工作日、双休日与节假日均可送货</label></td>
                                        </tr>
                                        <tr>
                                          <td><label>
                                            <input type="radio" name="songhuoshijian" value="只工作日送货">
                                          只工作日送货(双休日、假日不用送)(注:写字楼/商用地址客户请选择)</label></td>
                                        </tr>
                                        <tr>
                                          <td><label>
                                            <input type="radio" name="songhuoshijian" value="学校地址/地址白天没人,请尽量安排其他时间送货">
                                          学校地址/地址白天没人,请尽量安排其他时间送货(注:特别安排可能超出预计送货天数)</label></td>
                                        </tr>
                                      </table></td>
                                    </tr>
                                    <tr>
                                      <td width="23%" height="0" valign="top">                                      </td>
                                      <td width="77%" height="0" valign="top">
                                        <INPUT class=btn id=button type=submit name=button><STRONG
class=submitcolor>提交订单后,请保持您的电话畅通,我们会在3-5个工作日为您送货上门。</STRONG></td>
                                    </tr>
                                  </table>
                                </div></td>
                            </tr>
                          </table>
              </form>



这个是连接数据库代码文件。
<!--#include file="Inc/Conn.asp"-->
<%
Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from dinggou"  '这里添加新数据
rs.open sql,conn,1,3
rs.addnew            '开始新数据

rs("title")=trim(request.form("title")) '将数据添加到字段
rs("Price")=trim(request.form("Price"))     '将数据添加到字段
rs("shuliang")=trim(request.form("shuliang"))    '将数据添加到字段
rs("Receiver")=trim(request.form("Receiver"))    '同上
rs("Add")=trim(request.form("Add"))    '将数据添加到字段
rs("Postcode")=trim(request.form("Postcode"))     '同上
rs("Phone")=trim(request.form("Phone"))     '将数据添加到字段1
rs("Mobile")=trim(request.form("Mobile"))     '同上
rs("PayType")=trim(request.form("PayType"))     '将数据添加到字段
rs("songhuoshijian")=trim(request.form("songhuoshijian"))    '同上
rs.update        '开始向数据库写入
rs.close        '关闭rs记录
set rs=nothing        '清除rs记录集
Response.Write("<script language=""JavaScript"">alert(""提交订单成功"");history.go(-1);</script>")
%>
搜索更多相关主题的帖子: 数据库 title ASP 
2010-06-14 23:55
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:10 
在表单内提交就能在提交页面获得了,你这个代码不是已经写入数据库了?
2010-06-16 21:53
hams
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:18
帖 子:912
专家分:3670
注 册:2008-7-30
收藏
得分:10 
你提供的程序都已经在注释里写得很清楚了,如果还看不明白,建议你还是好好学一下基础知识。

俺不高手,俺也是来学习的。
俺的意见不一定就对,当你不认同时请点忽视按钮。
当走到十字路口不知该如何走时,可在论坛问下路,但你若希望别人能一路把你送到目的地,显然是不现实的,因为别人也有自己要走的路。
2010-06-17 08:27
快速回复:刚学的ASP,怎样将<%=rs("title")%>传递来的title写进数据库? ...
数据加载中...
 
   



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

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