熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

asp調用二級分類代碼

2013-11-13 10:36:44  來源: .NET編程 

  <%
 dim conn
 dim connstr
 dim db
 db="/data/duasp"
 Set conn = ServerCreateObject("ADODBConnection")
 connstr="Provider=MicrosoftJetOLEDB;Data Source=" & ServerMapPath(db)
 connOpen connstr
 
 sub closedatabase()
   connclose
        set conn=Nothing
    End sub
%>
<title>錯誤提示</title>
<meta httpequiv="ContentType" content="text/html; charset=gb">
<%
dim founderrerrmsg
founderr=false
errmsg=""

  if Requestform("MM_insert") then

  if requestform("action")="newp" then
sql="select * from p_class_small"
set rs=servercreateobject("adodbrecordset")
rsopen sqlconn
rsaddnew
dim p_small_typep_type
p_small_type=trim(replace(requestform("p_small_type")""""))
p_type=trim(replace(requestform("p_type")""""))
p_small_type_e=trim(replace(requestform("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=servercreateobject("adodbrecordset")
            rs_popen sql_pconn
   if Not(rs_pBOF and rs_pEOF) then
      p_type_e=rs_p("p_type_e")
   end if
   rs_pclose
   set rs_p=nothing 
rs("p_type_e")=p_type_e
rs("p_small_type_e")=p_small_type_e
if Not founderr then
rsupdate
rsclose
set rs=Nothing
  closedatabase
responseredirect "admin_p_smallasp"
else
Call diserror()
responseEnd
End if
End if

  if requestform("action")="editp" then
if requestForm("id")="" then
  founderr=true
  errmsg=errmsg+"<br>"+"<li>你必須指定操作的對象!"
else
  if Not isInteger(requestform("id")) then
    founderr=true
    errmsg=errmsg+"<br>"+"<li>非法的id參數"
  End if
End if
if founderr then
  Call diserror()
  responseEnd
End if
sql="select * from p_class_small where p_small_id="&cint(requestForm("id"))
set rs=servercreateobject("adodbrecordset")
rsopen sqlconn
p_old_small_type=rs("p_small_type")
p_old_small_type_e=rs("p_small_type_e")
p_small_type=trim(replace(requestform("p_small_type")""""))
p_type=trim(replace(requestform("p_type")""""))
p_small_type_e=trim(replace(requestform("p_small_type_e")""""))
p_type_e=trim(replace(requestform("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=servercreateobject("adodbrecordset")
            rs_popen sql_pconn
   if Not(rs_pBOF and rs_pEOF) then
      p_type_e=rs_p("p_type_e")
   end if
   rs_pclose
   set rs_p=nothing 
rs("p_type_e")=p_type_e
rs("p_small_type_e")=p_small_type_e

  if Not founderr then
rsupdate
rsclose
set rs=Nothing
連代更新屬於此小類的信息
v_sql="select * from p_info where p_small_type="&p_old_small_type&""
set v_rs=servercreateobject("adodbrecordset")
v_rsopen v_sqlconn
if Not(v_rsBOF or v_rsEOF) then
do while not v_rseof
v_rs("p_small_type")=p_small_type
v_rs("p_small_type_e")=p_small_type_e
v_rsupdate
v_rsmovenext
loop
End if
v_rsclose
set v_rs=Nothing
responseredirect "admin_p_smallasp"
else
Call diserror()
responseEnd
End if
End if

  if requestform("action")="delp" then
if requestForm("id")="" then
  founderr=true
  errmsg=errmsg+"<br>"+"<li>你必須指定操作的對象!"
else
  if Not isInteger(requestform("id")) then
    founderr=true
    errmsg=errmsg+"<br>"+"<li>非法的id參數"
  End if
End if
if founderr then
  Call diserror()
  responseEnd
End if
sql="select * from p_class_small where p_small_id="&cint(requestForm("id"))
set rs=servercreateobject("adodbrecordset")
rsopen sqlconn
if Not(rsBOF or rsEOF) then
rsdelete
End if
rsclose
set rs=Nothing
連代刪除屬於此分類的信息
v_sql="select * from p_info where p_small_type="&p_small_type&""
set v_rs=servercreateobject("adodbrecordset")
v_rsopen v_sqlconn
if Not(v_rsBOF or v_rsEOF) then
do while not v_rseof
v_rsdelete
v_rsmovenext
loop
End if
v_rsclose
set v_rs=Nothing
closedatabase
responseredirect "admin_p_smallasp"
End if
End if

  Call p_small_body()
closedatabase
%>


From:http://tw.wingwit.com/Article/program/net/201311/14121.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.