asp調用二級分類 代碼

來源:互聯網
上載者:User

asp調用二級分類 代碼
<%
 dim conn
 dim connstr
 dim db
 db="../data/1du.asp"
 Set conn = Server.CreateObject("ADODB.Connection")
 connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
 conn.Open connstr
 
 sub closedatabase()
   conn.close
        set conn=Nothing
    End sub
%>


<title>錯誤提示</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
dim founderr,errmsg
founderr=false
errmsg=""

if Request.form("MM_insert") then

if request.form("action")="newp" then
sql="select * from p_class_small"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
rs.addnew
dim p_small_type,p_type
p_small_type=trim(replace(request.form("p_small_type"),"'",""))
p_type=trim(replace(request.form("p_type"),"'",""))
p_small_type_e=trim(replace(request.form("p_small_type_e"),"'",""))
if p_small_type="" then
  founderr=true
  errmsg=errmsg+"<br>"+"<li>你必須輸入欄目名稱名稱!"
else
  rs("p_small_type")=p_small_type
End if
if p_type="" then
  founderr=true
  errmsg=errmsg+"<br>"+"<li>你必須選擇一級分類!"
else
  rs("p_type")=p_type
End if
'由P_type得到p_type_e
   sql_p="select p_type_e from p_class where p_type='"&p_type&"'"
            set rs_p=server.createobject("adodb.recordset")
            rs_p.open sql_p,conn,1,1
   if Not(rs_p.BOF and rs_p.EOF) then
      p_type_e=rs_p("p_type_e")
   end if
   rs_p.close
   set rs_p=nothing 
rs("p_type_e")=p_type_e
rs("p_small_type_e")=p_small_type_e
if Not founderr then
rs.update
rs.close
set rs=Nothing
  closedatabase
response.redirect "admin_p_small.asp"
else
Call diserror()
response.End
End if
End if

if request.form("action")="editp" then
if request.Form("id")="" then
  founderr=true
  errmsg=errmsg+"<br>"+"<li>你必須指定操作的對象!"
else
  if Not isInteger(request.form("id")) then
    founderr=true
    errmsg=errmsg+"<br>"+"<li>非法的id參數。"
  End if
End if
if founderr then
  Call diserror()
  response.End
End if
sql="select * from p_class_small where p_small_id="&cint(request.Form("id"))
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
p_old_small_type=rs("p_small_type")
p_old_small_type_e=rs("p_small_type_e")
p_small_type=trim(replace(request.form("p_small_type"),"'",""))
p_type=trim(replace(request.form("p_type"),"'",""))
p_small_type_e=trim(replace(request.form("p_small_type_e"),"'",""))
p_type_e=trim(replace(request.form("p_type_e"),"'",""))
if p_small_type="" then
  founderr=true
  errmsg=errmsg+"<br>"+"<li>你必須輸入欄目名稱!"
else
  rs("p_small_type")=p_small_type
End if
if p_type="" then
  founderr=true
  errmsg=errmsg+"<br>"+"<li>你必須選擇一級分類!"
else
  rs("p_type")=p_type
End if
'由P_type得到p_type_e
   sql_p="select p_type_e from p_class where p_type='"&p_type&"'"
            set rs_p=server.createobject("adodb.recordset")
            rs_p.open sql_p,conn,1,1
   if Not(rs_p.BOF and rs_p.EOF) then
      p_type_e=rs_p("p_type_e")
   end if
   rs_p.close
   set rs_p=nothing 
rs("p_type_e")=p_type_e
rs("p_small_type_e")=p_small_type_e

if Not founderr then
rs.update
rs.close
set rs=Nothing
'連代更新屬於此小類的資訊
v_sql="select * from p_info where p_small_type='"&p_old_small_type&"'"
set v_rs=server.createobject("adodb.recordset")
v_rs.open v_sql,conn,1,3
if Not(v_rs.BOF or v_rs.EOF) then
do while not v_rs.eof
v_rs("p_small_type")=p_small_type
v_rs("p_small_type_e")=p_small_type_e
v_rs.update
v_rs.movenext
loop
End if
v_rs.close
set v_rs=Nothing
response.redirect "admin_p_small.asp"
else
Call diserror()
response.End
End if
End if

if request.form("action")="delp" then
if request.Form("id")="" then
  founderr=true
  errmsg=errmsg+"<br>"+"<li>你必須指定操作的對象!"
else
  if Not isInteger(request.form("id")) then
    founderr=true
    errmsg=errmsg+"<br>"+"<li>非法的id參數。"
  End if
End if
if founderr then
  Call diserror()
  response.End
End if
sql="select * from p_class_small where p_small_id="&cint(request.Form("id"))
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if Not(rs.BOF or rs.EOF) then
rs.delete
End if
rs.close
set rs=Nothing
'連代刪除屬於此分類的資訊
v_sql="select * from p_info where p_small_type='"&p_small_type&"'"
set v_rs=server.createobject("adodb.recordset")
v_rs.open v_sql,conn,1,3
if Not(v_rs.BOF or v_rs.EOF) then
do while not v_rs.eof
v_rs.delete
v_rs.movenext
loop
End if
v_rs.close
set v_rs=Nothing
closedatabase
response.redirect "admin_p_small.asp"
End if
End if

Call p_small_body()
closedatabase
%>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.