在改网站的时候遇到一个问题:
先看图片
产品价格、批发价格、库存数量、计价单位这四个输入框是必须输入的,如果不输内容保存时就会出错,如下:
Microsoft VBScript 运行时错误 错误 '800a000d'
类型不匹配: '[string: ""]'
/newweb/admin/ProductEdit.asp,行 307
能够改成不是必须录入或删除不出错都可以。
我把从205-554行以后的一些代码复制下来,请问下面的如何修改:
sub ProductEdit()
dim Action,rsRepeat,rs,sql
Action=request.QueryString("Action")
if Action="SaveEdit" then
set rs = server.createobject("adodb.recordset")
if len(trim(request.Form("ProductNameCh")))<1 then
response.write ("<script language=javascript> alert('""中文""名称为必填项目!');history.back(-1);</script>")
response.end
end if
if request.Form("ViewFlagEn")=1 then
if len(trim(request.Form("ProductNameEn")))<1 then
response.write ("<script language=javascript> alert('您已经选择了""英文""显示,因此英文名称必填!');history.back(-1);</script>")
response.end
end if
end if
if Result="Add" Then
set rsRepeat = conn.execute("select ProductNo from LiangJingCMS_Products where ProductNo='" & trim(Request.Form("ProductNo")) & "'")
if not (rsRepeat.bof and rsRepeat.eof) then
response.write "<script language='javascript'>alert('" & trim(Request.Form("ProductNo")) & "产品编号已存在!');history.back(-1);</script>"
response.End
End If
rsRepeat.close
set rsRepeat=Nothing
sql="select * from LiangJingCMS_Products"
rs.open sql,conn,1,3
rs.addnew
rs("ProductNameCh")=trim(Request.Form("ProductNameCh"))
rs("ProductNameEn")=trim(Request.Form("ProductNameEn"))
if Request.Form("ViewFlagCh")=1 then
rs("ViewFlagCh")=Request.Form("ViewFlagCh")
else
rs("ViewFlagCh")=0
end if
if Request.Form("ViewFlagEn")=1 then
rs("ViewFlagEn")=Request.Form("ViewFlagEn")
else
rs("ViewFlagEn")=0
end if
rs("SortID")=Request.Form("SortID")
rs("SortPath")=Request.Form("SortPath")
rs("ProductNo")=trim(Request.Form("ProductNo"))
rs("ProductModel")=trim(Request.Form("ProductModel"))
rs("N_Price")=Round(trim(Request.Form("N_Price")),2)
rs("P_Price")=Round(trim(Request.Form("P_Price")),2)
rs("Stock")=Round(trim(Request.Form("Stock")),2)
rs("UnitCh")=trim(Request.Form("UnitCh"))
rs("UnitEn")=trim(Request.Form("UnitEn"))
rs("MakerCh")=trim(Request.Form("MakerCh"))
rs("MakerEn")=trim(Request.Form("MakerEn"))
if Request.Form("CommendFlag")=1 then
rs("CommendFlag")=Request.Form("CommendFlag")
else
rs("CommendFlag")=0
end if
if Request.Form("NewFlag")=1 then
rs("NewFlag")=Request.Form("NewFlag")
else
rs("NewFlag")=0
end if
GroupIdName=split(Request.Form("GroupID"),"┎╂┚")
rs("GroupID")=GroupIdName(0)
rs("Exclusive")=trim(Request.Form("Exclusive"))
rs("BigPic")=trim(Request.Form("BigPic"))
rs("SmallPic")=trim(Request.Form("SmallPic"))
rs("ContentCh")=Request.Form("ContentCh")
rs("ContentEn")=Request.Form("ContentEn")
rs("AddTime")=now()
rs("UpdateTime")=now()
Num_1=CheckStr(Request.Form("Num_1"),1)
if Num_1="" then Num_1=0
if Num_1>0 then
For i=1 to Num_1
If CheckStr(Request.Form("attributeCH"&i),0)<>"" and CheckStr(Request.Form("attributeCH"&i&"_value"),0)<>"" Then
If attribute1CH="" then
attribute1CH=CheckStr(Request.Form("attributeCH"&i),0)
attribute1CH_value=CheckStr(Request.Form("attributeCH"&i&"_value"),0)
Else
attribute1CH=attribute1CH&"§§§"&CheckStr(Request.Form("attributeCH"&i),0)
attribute1CH_value=attribute1CH_value&"§§§"&CheckStr(Request.Form("attributeCH"&i&"_value"),0)
End if
End If
Next
end if
Num_2=CheckStr(Request.Form("Num_2"),1)
if Num_2="" then Num_2=0
if Num_2>0 then
For i=1 to Num_2
If CheckStr(Request.Form("attributeEN"&i),0)<>"" and CheckStr(Request.Form("attributeEN"&i&"_value"),0)<>"" Then
If attribute1EN="" then
attribute1EN=CheckStr(Request.Form("attributeEN"&i),0)
attribute1EN_value=CheckStr(Request.Form("attributeEN"&i&"_value"),0)
Else
attribute1EN=attribute1EN&"§§§"&CheckStr(Request.Form("attributeEN"&i),0)
attribute1EN_value=attribute1EN_value&"§§§"&CheckStr(Request.Form("attributeEN"&i&"_value"),0)
End if
End If
Next
end if
rs("attribute1CH")=attribute1CH
rs("attribute1CH_value")=attribute1CH_value
rs("attribute1EN")=attribute1EN
rs("attribute1EN_value")=attribute1EN_value
rs("SeoKeywordsCH")=trim(Request.Form("SeoKeywordsCH"))
rs("SeoDescriptionCH")=trim(Request.Form("SeoDescriptionCH"))
rs("SeoKeywordsEN")=trim(Request.Form("SeoKeywordsEN"))
rs("SeoDescriptionEN")=trim(Request.Form("SeoDescriptionEN"))
rs.update
rs.close
set rs=Nothing
set rs=server.createobject("adodb.recordset")
sql="select top 1 ID from LiangJingCMS_Products order by ID desc"
rs.open sql,conn,1,1
ID=rs("ID")
rs.close
set rs=Nothing
if ISHTML = 1 then
call htmll("/CH/","/CH/",""&ProName&""&Separated&""&ID&"."&HTMLName&"","ProductView.asp","ID=",ID,"","")
call htmll("/EN/","/EN/",""&ProName&""&Separated&""&ID&"."&HTMLName&"","ProductView.asp","ID=",ID,"","")
End If
End If
if Result="Modify" then
sql="select * from LiangJingCMS_Products where ID="&ID
rs.open sql,conn,1,3
rs("ProductNameCh")=trim(Request.Form("ProductNameCh"))
rs("ProductNameEn")=trim(Request.Form("ProductNameEn"))
if Request.Form("ViewFlagCh")=1 then
rs("ViewFlagCh")=Request.Form("ViewFlagCh")
else
rs("ViewFlagCh")=0
end if
if Request.Form("ViewFlagEn")=1 then
rs("ViewFlagEn")=Request.Form("ViewFlagEn")
else
rs("ViewFlagEn")=0
end if
rs("SortID")=Request.Form("SortID")
rs("SortPath")=Request.Form("SortPath")
rs("ProductNo")=trim(Request.Form("ProductNo"))
rs("ProductModel")=trim(Request.Form("ProductModel"))
rs("N_Price")=Round(trim(Request.Form("N_Price")),2)
rs("P_Price")=Round(trim(Request.Form("P_Price")),2)
rs("Stock")=Round(trim(Request.Form("Stock")),2)
rs("UnitCh")=trim(Request.Form("UnitCh"))
rs("UnitEn")=trim(Request.Form("UnitEn"))
rs("MakerCh")=trim(Request.Form("MakerCh"))
rs("MakerEn")=trim(Request.Form("MakerEn"))
if Request.Form("CommendFlag")=1 then
rs("CommendFlag")=Request.Form("CommendFlag")
else
rs("CommendFlag")=0
end if
if Request.Form("NewFlag")=1 then
rs("NewFlag")=Request.Form("NewFlag")
else
rs("NewFlag")=0
end if
GroupIdName=split(Request.Form("GroupID"),"┎╂┚")
rs("GroupID")=GroupIdName(0)
rs("Exclusive")=trim(Request.Form("Exclusive"))
rs("BigPic")=trim(Request.Form("BigPic"))
rs("SmallPic")=trim(Request.Form("SmallPic"))
rs("ContentCh")=Request.Form("ContentCh")
rs("ContentEn")=Request.Form("ContentEn")
rs("UpdateTime")=now()
Num_1=CheckStr(Request.Form("Num_1"),1)
if Num_1="" then Num_1=0
if Num_1>0 then
For i=1 to Num_1
If CheckStr(Request.Form("attributeCH"&i),0)<>"" and CheckStr(Request.Form("attributeCH"&i&"_value"),0)<>"" Then
If attribute1CH="" then
attribute1CH=CheckStr(Request.Form("attributeCH"&i),0)
attribute1CH_value=CheckStr(Request.Form("attributeCH"&i&"_value"),0)
Else
attribute1CH=attribute1CH&"§§§"&CheckStr(Request.Form("attributeCH"&i),0)
attribute1CH_value=attribute1CH_value&"§§§"&CheckStr(Request.Form("attributeCH"&i&"_value"),0)
End if
End If
Next
end if
Num_2=CheckStr(Request.Form("Num_2"),1)
if Num_2="" then Num_2=0
if Num_2>0 then
For i=1 to Num_2
If CheckStr(Request.Form("attributeEN"&i),0)<>"" and CheckStr(Request.Form("attributeEN"&i&"_value"),0)<>"" Then
If attribute1EN="" then
attribute1EN=CheckStr(Request.Form("attributeEN"&i),0)
attribute1EN_value=CheckStr(Request.Form("attributeEN"&i&"_value"),0)
Else
attribute1EN=attribute1EN&"§§§"&CheckStr(Request.Form("attributeEN"&i),0)
attribute1EN_value=attribute1EN_value&"§§§"&CheckStr(Request.Form("attributeEN"&i&"_value"),0)
End if
End If
Next
end if
rs("attribute1CH")=attribute1CH
rs("attribute1CH_value")=attribute1CH_value
rs("attribute1EN")=attribute1EN
rs("attribute1EN_value")=attribute1EN_value
rs("SeoKeywordsCH")=trim(Request.Form("SeoKeywordsCH"))
rs("SeoDescriptionCH")=trim(Request.Form("SeoDescriptionCH"))
rs("SeoKeywordsEN")=trim(Request.Form("SeoKeywordsEN"))
rs("SeoDescriptionEN")=trim(Request.Form("SeoDescriptionEN"))
rs.update
rs.close
set rs=Nothing
if ISHTML = 1 then
call htmll("/CH/","/CH/",""&ProName&""&Separated&""&ID&"."&HTMLName&"","ProductView.asp","ID=",ID,"","")
call htmll("/EN/","/EN/",""&ProName&""&Separated&""&ID&"."&HTMLName&"","ProductView.asp","ID=",ID,"","")
End If
End If
if ISHTML = 1 then
response.write "<script language='javascript'>alert('设置成功,相关静态页面已更新!');location.replace('ProductList.asp');</script>"
Else
response.write "<script language='javascript'>alert('设置成功!');location.replace('ProductList.asp');</script>"
End If
else
if Result="Modify" then
set rs = server.createobject("adodb.recordset")
sql="select * from LiangJingCMS_Products where ID="& ID
rs.open sql,conn,1,1
if rs.bof and rs.eof then
response.write ("<center>数据库记录读取错误!</center>")
response.end
end if
ProductNameCh=rs("ProductNameCh")
ProductNameEn=rs("ProductNameEn")
ViewFlagCh=rs("ViewFlagCh")
ViewFlagEn=rs("ViewFlagEn")
SortNameCH=SortText(rs("SortID"))
SortID=rs("SortID")
SortPath=rs("SortPath")
ProductNo=rs("ProductNo")
ProductModel=rs("ProductModel")
N_Price=rs("N_Price")
P_Price=rs("P_Price")
Stock=rs("Stock")
UnitCh=rs("UnitCh")
UnitEn=rs("UnitEn")
MakerCh=rs("MakerCh")
MakerEn=rs("MakerEn")
CommendFlag=rs("CommendFlag")
NewFlag=rs("NewFlag")
GroupID=rs("GroupID")
Exclusive=rs("Exclusive")
BigPic=rs("BigPic")
SmallPic=rs("SmallPic")
ContentCh=rs("ContentCh")
ContentEn=rs("ContentEn")
SeoKeywordsCH=rs("SeoKeywordsCH")
SeoDescriptionCH=rs("SeoDescriptionCH")
SeoKeywordsEN=rs("SeoKeywordsEN")
SeoDescriptionEN=rs("SeoDescriptionEN")
rs.close
set rs=nothing
else
randomize timer
ProductNo=Hour(now)&Minute(now)&Second(now)&"-"&int(900*rnd)+100
Stock=10000
end if
end if
end sub