亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 開發 > XML > 正文

實戰ASP(8):使用ASP、VB和XML建立運行于互聯網上的應用程序(下)

2024-09-05 20:55:41
字體:
來源:轉載
供稿:網友
使用asp、vb和xml建立運行于互聯網上的應用程序(2)
      在實際的編程過程中,你們應當使用一些方法使應用程序更加有高效性。你可以把asp中的關于取得數據的代碼端搬到一個com應用程序中去然后創建一個xslt變換來顯示返回的數據。好,我不多說了,現在你所要做的就是試一試吧!

   option explicit
   private rcommands as recordset
   private rcustomers as recordset
   private rcust as recordset
   private scustlistcommand as string
   private const dataurl = "http://localhost/xhttprequest/getdata.asp"
   private arrcustomerids() as string
   private enum actionenum
   view_history = 0
   view_recent_product = 1
  end enum

  private sub dgcustomers_click()
   dim customerid as string
   customerid = rcustomers("customerid").value
   if customerid <> "" then
    if optaction(view_history).value then
     call getcustomerdetail(customerid)
    else
     call getrecentproduct(customerid)
    end if
   end if
  end sub

  private sub form_load()
   call initialize
   call getcustomerlist
  end sub

  sub initialize()
   ' 從數據庫返回命令名和相應的值

   dim sxml as string
   dim vret as variant
   dim f as field
   sxml = "<?xml version=""1.0""?>"
   sxml = sxml & "<command><commandtext>initialize</commandtext>"
   sxml = sxml & "<returnsdata>true</returnsdata>"
   sxml = sxml & "</command>"
   set rcommands = getrecordset(sxml)
   do while not rcommands.eof
    for each f in rcommands.fields
     debug.print f.name & "=" & f.value
    next
    rcommands.movenext
   loop
  end sub

  function getcommandxml(command_name as string) as string
   rcommands.movefirst
   rcommands.find "command_name='" & command_name & "'", , adsearchforward, 1
   if rcommands.eof then
    msgbox "cannot find any command associated with the name '" & command_name & "'."
    exit function
   else
    getcommandxml = rcommands("command_xml")
   end if
  end function

  sub getrecentproduct(customerid as string)
   dim sxml as string
   dim xml as domdocument
   dim n as ixmldomnode
   dim productname as string
   sxml = getcommandxml("recentpurchasebycustomerid")
   set xml = new domdocument
   xml.loadxml sxml
   set n = xml.selectsinglenode("command/param[name='customerid']/value")
   n.text = customerid
   set xml = executespwithreturn(xml.xml)
   productname = xml.selectsinglenode("values/productname").text
   ' 顯示text域
   txtresult.text = ""
   me.txtresult.visible = true
   dgresult.visible = false
   ' 顯示product名
   txtresult.text = "最近的產品是: " & productname
  end sub

  sub getcustomerlist()
   dim sxml as string
   dim i as integer
   dim s as string
   sxml = getcommandxml("getcustomerlist")
   set rcustomers = getrecordset(sxml)
   set dgcustomers.datasource = rcustomers
  end sub

  sub getcustomerdetail(customerid as string)
   ' 找出列表中相關聯的id號
   dim sxml as string
   dim r as recordset
   dim f as field
   dim s as string
   dim n as ixmldomnode
   dim xml as domdocument
   sxml = getcommandxml("custorderhist")
   set xml = new domdocument
   xml.loadxml sxml
   set n = xml.selectsinglenode("command/param[name='customerid']/value")
   n.text = customerid
   set r = getrecordset(xml.xml)
   ' 隱藏 text , 因為它是一個記錄集
   txtresult.visible = false

   dgresult.visible = true
   set dgresult.datasource = r
  end sub

  function getrecordset(sxml as string) as recordset
   dim r as recordset
   dim xml as domdocument
   set xml = getdata(sxml)
    debug.print typename(xml)
   on error resume next
   set r = new recordset
   r.open xml
   if err.number <> 0 then
    msgbox err.description
    exit function
   else
    set getrecordset = r
   end if
  end function

  function executespwithreturn(sxml as string) as domdocument
   dim d as new dictionary
   dim xml as domdocument
   dim nodes as ixmldomnodelist
   dim n as ixmldomnode
   set xml = getdata(sxml)
   if xml.documentelement.nodename = "values" then
    set executespwithreturn = xml
   else
    '發生錯誤
 
    set n = xml.selectsinglenode("response/data")
    if not n is nothing then
     msgbox n.text
     exit function
    else
     msgbox xml.xml
     exit function
    end if
   end if
  end function

  function getdata(sxml as string) as domdocument
   dim xhttp as new xmlhttp30
   xhttp.open "post", dataurl, false
   xhttp.send sxml
   debug.print xhttp.responsetext
   set getdata = xhttp.responsexml
  end function

  private sub optaction_click(index as integer)
   call dgcustomers_click
  end sub


  代碼二、getdata.asp

  ?。?@ language=vbscript %>
  ?。? option explicit %>
   <%
    sub responseerror(sdescription)
    response.write "<res

|||中國最大的web開發資源網站及技術社區,
ponse><data>error: " & sdescription & "</data></response>"
    response.end
   end sub

   response.contenttype="text/xml"
   dim xml
   dim commandtext
   dim returnsdata
   dim returnsvalues
   dim recordsaffected
   dim param
   dim paramname
   dim paramtype
   dim paramdirection
   dim paramsize
   dim paramvalue
   dim n
   dim nodename
   dim nodes
   dim conn
   dim sxml
   dim r
   dim cm

    ' 創建domdocument對象
   set xml = server.createobject("msxml2.domdocument")
   xml.async = false

   ' 裝載post數據
   xml.load request
   if xml.parseerror.errorcode <> 0 then
    call responseerror("不能裝載 xml信息。 描述: " & xml.parseerror.reason & "<br>行數: " & xml.parseerror.line)
   end if

   ' 客戶端必須發送一個commandtext元素
   set n = xml.selectsinglenode("command/commandtext")
   if n is nothing then
    call responseerror("missing <commandtext> parameter.")
   else
    commandtext = n.text
   end if

   ' 客戶端必須發送一個returnsdata或者returnsvalue元素
   set n = xml.selectsinglenode("command/returnsdata")
   if n is nothing then
    set n = xml.selectsinglenode("command/returnsvalues")
    if n is nothing then
     call responseerror("missing <returnsdata> or <returnsvalues> parameter.")
    else
     returnsvalues = (lcase(n.text)="true")
    end if
   else
    returnsdata=(lcase(n.text)="true")
   end if

   set cm = server.createobject("adodb.command")
   cm.commandtext = commandtext
   if instr(1, commandtext, " ", vbbinarycompare) > 0 then
    cm.commandtype=adcmdtext
   else
    cm.commandtype = adcmdstoredproc
   end if

   ' 創建參數
   set nodes = xml.selectnodes("command/param")
   if nodes is nothing then' 如果沒有參數
   elseif nodes.length = 0 then
     ' 如果沒有參數
   else
     for each param in nodes
      ' response.write server.htmlencode(param.xml) & "<br>"
      on error resume next
      paramname = param.selectsinglenode("name").text
      if err.number <> 0 then
       call responseerror("創建參數: 不能發現名稱標簽。")
      end if
      paramtype = param.selectsinglenode("type").text
      paramdirection = param.selectsinglenode("direction").text
      paramsize = param.selectsinglenode("size").text
      paramvalue = param.selectsinglenode("value").text
      if err.number <> 0 then
        call responseerror("參數名為 '" & paramname & "'的參數缺少必要的域")
      end if
      cm.parameters.append                    cm.createparameter(paramname,paramtype,paramdirection,paramsize,paramvalue)
      if err.number <> 0 then
       call responseerror("不能創建或添加名為 '" & paramname & "的參數.' " & err.description)
        response.end
      end if
     next
     on error goto 0
    end if

   '打開連結
   set conn = server.createobject("adodb.connection")
   conn.mode=admodereadwrite
   conn.open application("connectionstring")
   if err.number <> 0 then
    call responseerror("連結出錯: " & err.description)
    response.end
   end if

  ' 連結command對象
  set cm.activeconnection = conn

  ' 執行命令
  if returnsdata then
   ' 用命令打開一個recordset
    set r = server.createobject("adodb.recordset")
    r.cursorlocation = aduseclient
    r.open cm,,adopenstatic,adlockreadonly
  else
    cm.execute recordsaffected, ,adexecutenorecords
  end if
   if err.number <> 0 then
    call responseerror("執行命令錯誤 '" & commandtext & "': " & err.description)
    response.end
   end if

   if returnsdata then
    r.save response, adpersistxml
    if err.number <> 0 then
     call responseerror("數據集發生存儲錯誤,在命令'" & commandtext & "': " & err.description)
     response.end
    end if
   elseif returnsvalues then
    sxml = "<?xml version=""1.0"" encoding=""gb2312""?>" & vbcrlf & "<values>"
    set nodes = xml.selectnodes("command/param[direction='2']")
    for each n in nodes
     nodename = n.selectsinglenode("name").text
     sxml = sxml & "<" & nodename & ">" & cm.parameters(nodename).value & "" & "</" & nodename & ">"
     next
     sxml = sxml & "</values>"
     response.write sxml
   end if

   set cm = nothing
   conn.close
   set r = nothing
   set conn = nothing
   response.end
  %>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
欧美日韩国产精品一区二区不卡中文| 国产成人精品久久| 91极品视频在线| 久久成人免费视频| 久久九九有精品国产23| 久久电影一区二区| 136fldh精品导航福利| 98精品国产自产在线观看| 欧美午夜影院在线视频| 性欧美激情精品| 色香阁99久久精品久久久| 久久99久久亚洲国产| 国产精品第3页| 国产精品第一第二| 国产精品高潮呻吟视频| 91av在线免费观看视频| 亚洲色图50p| 亚洲欧洲av一区二区| 欧美日韩成人在线观看| 国产精品自拍小视频| 97视频在线观看免费| 91精品国产自产在线观看永久| 影音先锋欧美在线资源| 精品中文字幕在线观看| 亚洲成色999久久网站| 亚洲精品综合久久中文字幕| 欧美中文字幕视频在线观看| 国产精品电影在线观看| 国产精品自在线| 国产精品久久久久久久app| 欧美老妇交乱视频| 国产精品69久久| 91视频国产高清| 久久亚洲精品一区二区| 日韩国产精品亚洲а∨天堂免| 国产在线精品播放| 国产精品网红福利| 成人激情av在线| 久久成人精品视频| 国产日本欧美在线观看| 亚洲综合在线做性| 91网站在线免费观看| 精品少妇v888av| 福利视频一区二区| 欧美巨猛xxxx猛交黑人97人| 国产亚洲精品久久久久久| 日韩美女av在线| 国产精品一二三在线| 久久99热这里只有精品国产| 人人爽久久涩噜噜噜网站| 日韩精品亚洲精品| 精品国产91乱高清在线观看| 亚洲a在线播放| 亚洲精品福利在线观看| 欧美电影《睫毛膏》| 日韩最新av在线| 成人黄色中文字幕| 欧美成人一区在线| 国内外成人免费激情在线视频| 亚洲18私人小影院| 在线电影av不卡网址| 91中文字幕一区| 欧洲美女免费图片一区| 亚洲成人久久电影| 久久久亚洲欧洲日产国码aⅴ| 91精品啪aⅴ在线观看国产| 国产在线精品一区免费香蕉| 色综合伊人色综合网站| 国产精品成人播放| 精品久久久香蕉免费精品视频| 中文字幕av一区二区三区谷原希美| 亚洲欧美另类国产| 国产精品美女主播在线观看纯欲| 久久久久久久999精品视频| 亚洲欧美另类国产| 亚洲午夜精品视频| 色综合色综合久久综合频道88| 日本一欧美一欧美一亚洲视频| 精品国产成人在线| 久久亚洲综合国产精品99麻豆精品福利| 欧美福利视频在线观看| 国产suv精品一区二区| 69久久夜色精品国产7777| 在线精品视频视频中文字幕| 欧美日韩国产色| 91精品久久久久久久久不口人| 成人淫片在线看| 91亚洲国产精品| 91免费看视频.| 日本19禁啪啪免费观看www| 91精品国产网站| 久久久久999| 欧美日韩成人免费| 国产不卡在线观看| 日本三级韩国三级久久| 国产精品91免费在线| 欧美华人在线视频| 57pao精品| 一个色综合导航| 日韩禁在线播放| 欧美裸体xxxx极品少妇软件| 国产精品第二页| 日韩美女主播视频| 美日韩丰满少妇在线观看| 国产日韩在线亚洲字幕中文| 国产亚洲aⅴaaaaaa毛片| 欧美一区二区视频97| 欧美激情亚洲一区| 国产91精品久久久久| 亚洲香蕉伊综合在人在线视看| 日韩成人av网| 91社影院在线观看| 97在线看免费观看视频在线观看| 中文字幕亚洲精品| 亚洲色无码播放| 国产亚洲精品综合一区91| 欧美丝袜一区二区三区| 色天天综合狠狠色| 日韩精品999| 欧美日韩国产中文精品字幕自在自线| 日韩精品欧美国产精品忘忧草| 欧美亚洲成人网| 亚洲va国产va天堂va久久| 中文字幕欧美精品在线| 69av视频在线播放| 中文字幕亚洲欧美在线| 日韩视频免费大全中文字幕| 亚洲欧美制服综合另类| 2023亚洲男人天堂| 亚洲三级av在线| 久久成人这里只有精品| 久久中文字幕在线| 91av在线网站| 国产91精品在线播放| 亚洲精品美女久久久久| 91探花福利精品国产自产在线| 亚洲国产精品成人精品| 亚洲精品成人久久久| 久久夜精品va视频免费观看| 精品视频—区二区三区免费| 国产精品一香蕉国产线看观看| 国模gogo一区二区大胆私拍| 国产伊人精品在线| 精品露脸国产偷人在视频| 韩国国内大量揄拍精品视频| 精品国偷自产在线| 91禁国产网站| 国产狼人综合免费视频| 都市激情亚洲色图| 亚洲欧洲一区二区三区久久| 色中色综合影院手机版在线观看| 欧美在线性视频| 久久综合免费视频影院| 欧美一级片在线播放| 97视频com| 成人福利在线观看| 大桥未久av一区二区三区| 久热精品视频在线观看| 久久久免费高清电视剧观看| 日韩中文字幕欧美| 91久久精品视频| 奇米成人av国产一区二区三区| 国产视频综合在线| 国产999精品视频|