批量添加问题,貌似解决了,大家一起看下是否正确方法。
其中 dim jfor j=kaishi to jieshu 是我要定义的循环批量添加数字想要在product_name和pic上添加循环数字!
接触asp时间不长。大多自学。如果是rs.update方式的我会弄conn.execute "insert into方式的我弄了很长时间不行。还分开获取编号id。看了置顶的帖子(那帖子很强大,粗略看了一下,有时间仔细去看,很实用)
大家一起探讨一下吧。脑很迷糊现在。。
贴上代码,求教!!!
access数据库!
<%
'开始添加商品
id=request("id")
bianhao1=date()
bianhao1=replace(bianhao1, "-", "")
bianhao1=replace(bianhao1, " ", "")
bianhao1=replace(bianhao1, ":", "")
bianhao=request("bianhao")
ifbianhao=request("ifbianhao")
product_name=trim(request("product_name"))
price=request("price")
sprice=request("sprice")
pfprice=request("pfprice")
vprice=request("vprice")
if vprice="" then vprice=""
cprice=request("cprice")
if cprice="" then cprice=""
cbprice=request("cbprice")
if cbprice="" then cbprice="0"
sort_name=request("sort_name")
csort_name=request("csort_name")
cxsort_name=request("cxsort_name")
cysort_name=request("cysort_name")
pro1=request("pro1")
pro2=request("pro2")
pro3=request("pro3")
pro4=request("pro4")
pro5=request("pro5")
pro6=request("pro6")
pro7=request("pro7")
pro8=request("pro8")
pro6_name=request("pro6_name")
pro7_name=request("pro7_name")
info=request("info")
siminfo=replace(request("siminfo"), ">", ">")
siminfo=replace(siminfo, "<", "<")
siminfo=replace(siminfo, "'","’")
if siminfo="" then siminfo="No infomation!"
stj=request("stj")
ytj=request("ytj")
cx=request("cx")
pic=request("pic")
if pic="" then pic="noimages.gif"
cpic=request("cpic")
if cpic="" then cpic="nonegif.gif"
cinfo=request("cinfo")
bzhuang=request("bzhuang")
company=request("company")
brand=request("brand")
zhuangtai=request("zhuangtai")
dim day
day=now()
if request("action")="add" then
'开始检测此产品名是否重复登陆
set rs=server.createobject("ADODB.Recordset")
sql="select * from 56770_product where product_name='"&product_name&"' order by id desc"
rs.open sql, conn, 1, 1
if not(rs.eof or rs.bof)then
response.write"<SCRIPT language=JavaScript>alert('对不起,您所添加的商品其商品名已经存在, 请核实!');"
response.write"javascript:history.go(-1)</SCRIPT>"
rs.close
set rs=nothing
response.end
end if
'结束检验,添加商品
dim j
for j=kaishi to jieshu
conn.execute "insert into 56770_product (product_name,price, sprice, vprice, cprice,cbprice, pfprice,info, pic, cpic, company, brand, sort_name, csort_name, cxsort_name, cysort_name, cinfo, bzhuang,pro1,pro2,pro3,pro4,pro5,pro6,pro7,pro8,pro6_name,pro7_name,ifbianhao,zhuangtai,siminfo)values('"&product_name&"', "&price&", "&sprice&", "&vprice&", "&cprice&","&cbprice&", "&pfprice&",'"&info&"', '"&pic&"', '"&cpic&"', '"&company&"', '"&brand&"', '"&sort_name&"', '"&csort_name&"', '"&cxsort_name&"', '"&cysort_name&"', '"&cinfo&"', '"&bzhuang&"','"&pro1&"','"&pro2&"','"&pro3&"','"&pro4&"','"&pro5&"','"&pro6&"','"&pro7&"','"&pro8&"','"&pro6_name&"','"&pro7_name&"','"&ifbianhao&"',1,'"&siminfo&"')"
'取得添加商品ID,添加商品编号及推荐促销项目
set rs=server.createobject("ADODB.Recordset")
sql="select * from 56770_product order by id desc"
rs.open sql, conn, 1, 1
id=rs("id")
rs.close
set rs=nothing
if request("ifbianhao")="1" then
bianhao=bianhao1&id
else
bianhao=request("bianhao")
end if
conn.execute "update 56770_product set bianhao='"&bianhao&"' where id=" & id
'判断为何推荐
'if etj="on" then conn.execute "update 56770_product set etj=true where id=" & id
if cx="on" then conn.execute "update 56770_product set cx=true where id=" & id
if stj="on" then conn.execute "update 56770_product set stj=true where id=" & id
if ytj="on" then conn.execute "update 56770_product set ytj=true where id=" & id
conn.execute "update 56770_product set day=now() where id=" & id
response.write"<SCRIPT language=JavaScript>alert('商品添加成功 返回继续添加!');"
response.write"javascript:history.go(-2)</SCRIPT>"
response.end
end if
%>
[ 本帖最后由 huangjunyi 于 2013-9-26 10:01 编辑 ]