麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 開發 > XML > 正文

用ASP、VB和XML建立互聯網應用程序(4)

2024-09-05 20:55:54
字體:
來源:轉載
供稿:網友
前面我們已經介紹了使用asp和xml混合編程,那是因為asp頁面能夠很容易讓我們看清應用程序正在做什么,但是你如果你不想使用asp的話,你也可以使用任何你熟悉的技術去創建一個客戶端程序。下面,我提供了一段vb代碼,它的功能和asp頁面一樣,也可以顯示相同的數據,但是這個vb程序不會創建發送到服務器的xml字符串。它通過運行一個名叫initialize的存儲過程,從服務器取回xml字符串,來查詢clientcommands表的內容。

  clientcommands表包括兩個域:command_name域和command_xml域。客戶端程序需要三個特定的command_name域:getcustomerlist,custorderhist和recentpurchasebycustomerid。每一個命令的command_xml域包括程序發送到getdata.asp頁面的xml字符串,這樣,就可以集中控制xml字符串了,就象存儲過程名字所表現的意思一樣,在發送xml字符串到getdata.asp之前,客戶端程序使用xml dom來設置存儲過程的參數值。我提供的代碼,包含了用于定義initialize過程和用于創建clientcommands表的sql語句。

  我提供的例程中還說明了如何使用xhttprequest對象實現我在本文一開始時許下的承諾:任何遠程的機器上的應用程序都可以訪問getdata.asp;當然,你也可以通過設置iis和ntfs權限來限制訪問asp頁面;你可以在服務器上而不是客戶機上存儲全局應用程序設置;你可以避免通過網絡發送數據庫用戶名和密碼所帶來的隱患性。還有,在ie中,應用程序可以只顯示需要的數據而不用刷新整個頁面。

  在實際的編程過程中,你們應當使用一些方法使應用程序更加有高效性。你可以把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



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 亚洲一区二区三区视频免费 | 免费一级毛片在线播放不收费 | 欧美精品免费一区二区三区 | 粉嫩粉嫩一区二区三区在线播放 | 久草在线观看福利视频 | 国产区二区 | 视频一区二区精品 | 久久国产精品久久久久 | 国产精品一区二区手机在线观看 | 性高潮一级片 | 久草在线最新免费 | 免费在线中文字幕 | 久久久久久久久久久久久国产精品 | 国产亚洲精品久久久久久久久 | 欧美一级高潮 | 福利在线免费 | 一级黄色在线观看 | 中文字幕在线观看国产 | 小雪奶水翁胀公吸小说最新章节 | 狠狠操视频网站 | 13一14毛片免费看 | 成人一区二区三区在线 | 日韩黄色免费观看 | 亚洲一级网站 | av在线高清观看 | 欧美成人免费一级 | 亚洲一区在线免费视频 | 在线观看国产日韩 | 免费的性生活视频 | 国产成人精品免高潮在线观看 | 欧美亚洲国产一区二区三区 | 久久国产亚洲精品 | 国产99视频精品免视看9 | 一级黄色电影网站 | 亚洲免费永久 | 18一20岁一级毛片 | 中文字幕网在线 | 日韩精品中文字幕在线播放 | 欧美一区二区三区免费观看 | 一级黄色毛片子 | 一级做a爱片久久毛片a高清 |