问题描述:在后台添加新的栏目时,弹出错误“执行SQL语句错误”!栏目有三级目录:
1级栏目为“产品中心”,数据库表中以DeepPath赋值1来表示是一级目录;
2级栏目为“切割工具”,数据库表中以DeepPath赋值2来表示是二级目录;
3级栏目为“切刀”,数据库表中以DeepPath赋值3来表示是三级目录;现在出现的问题是,我在后台需要再添加“切割工具”下的新栏目“切钳”,应该是三级目录,这时就出错了,我是查看数据库表中DeepPath赋值为1,才知道是成了一级目录而报错的。添加栏目时选择对应二级栏目“切割工具”是没有错的。附上代码:(中间的一段代码)......Sub saveColumnType
dim ChildPath,DeepPath,NavName,WebType,ParentID,OpenType,OpenUrl,Sequence,ColumnInfo,actType,IsShow,NavPic
NavName = getForm("NavName","post")
ParentID = getForm("ParentID","post")
OpenUrl = getForm("LinkUrl","post")
WebType = getForm("WebType","post") : if isNul(WebType) then WebType=0
IsShow = getForm("isshow","post")
NavPic = getForm("m_pic","post")
Sequence = getForm("Sequence","post") : if isNul(Sequence) then Sequence=conn.db("select max(Sequence)+1 from {pre}Navigation","0")(0)
if not isNum(Sequence) then Sequence=1
if isNul(NavName) then alertback "信息填写不完整,请检查"
ColumnInfo = codeTextarea(getForm("ColumnInfo","post"),"en")
actType = getForm("acttype","get")
select case  actType
case "edit"
    dim m_id:m_id=clng(getForm("m_id","post"))
conn.db "update {pre}Navigation set NavName='"&NavName&"',WebType="&WebType&",NavUrl='"&OpenUrl&"',Sequence="&Sequence&",ColumnInfo='"&ColumnInfo&"',IsShow="&Isshow&",NavPic='"&NavPic&"' where ID="&m_id&"","0"
alert "","admin_column.asp"
case "add"
    OpenType = cint(getForm("NavNature","post"))
conn.db "insert into {pre}Navigation([NavName],[WebType],[ParentID],[Sequence],[ColumnInfo],[isOut],[NavUrl],[IsShow],[NavPic]) values('"&NavName&"',"&WebType&","&ParentID&","&Sequence&",'"&ColumnInfo&"',"&OpenType&",'"&OpenUrl&"',"&Isshow&",'"&NavPic&"')","0" 
conn.db "update {pre}Navigation set ChildPath=ID where ID=(select top 1 ID from {pre}Navigation order by ID desc)","0"
conn.db "update {pre}Navigation set DeepPath=1 where ID=(select top 1 ID from {pre}Navigation order by ID desc)","0"
if ParentID<>0 then 
addChildPath(ParentID)
addDeepPath(ParentID)
conn.db "update {pre}Navigation set DeepPath=DeepPath+1 where ID=(select top 1 ID from {pre}Navigation order by ID desc)","0"
end if
alert "","admin_column.asp"
    end select
End SubSub addChildPath(ID)
    dim TemptStr,sqlStr,rsObj
    dim ParentID : ParentID=ID
if ParentID<>0 then
sqlStr= "select top 1 ID from {pre}Navigation order by ID desc"
set rsObj = conn.db(sqlStr,"1")
TemptStr=rsObj("ID")
rsObj.close
set rsObj = nothing
conn.db "update {pre}Navigation set ChildPath=ChildPath+','+'"&TemptStr&"' where ID="&ParentID&"","0"
sqlStr= "select ParentID from {pre}Navigation where ID="&ParentID&""
set rsObj = conn.db(sqlStr,"1")
    addChildPath(rsObj("ParentID"))
rsObj.close
set rsObj = nothing
end if
End SubSub addDeepPath(ID)
    dim sqlStr,rsObj
dim ParentID : ParentID=ID
if ParentID<>0 then
    sqlStr= "select * from {pre}Navigation where ID="&ParentID&""
set rsObj = conn.db(sqlStr,"1")
if rsObj("ParentID")<>0 then
   conn.db "update {pre}Navigation set DeepPath=DeepPath+1 where ID=(select top 1 ID from {pre}Navigation order by ID desc)","0" 
   addDeepPath(rsObj("ParentID"))
end if
rsObj.close
    set rsObj = nothing
end if
End Sub......