当前位置: 移动技术网 > IT编程>开发语言>.net > 用ASP、VB和XML建立互联网应用程序(4)

用ASP、VB和XML建立互联网应用程序(4)

2018年10月17日  | 移动技术网IT编程  | 我要评论

麦糖礼盒,淘宝系统异常,剖海螺挖出珍珠

前面我们已经介绍了使用asp和xml(标准化越来越近了)混合,那是因为asp页面能够很容易让我们看清应用程序正在做什么,但是你如果你不想使用asp的话,你也可以使用任何你熟悉的技术去创建一个客户端程序。下面,我提供了一段vb代码,它的功能和asp页面一样,也可以显示相同的数据,但是这个vb程序不会创建发送到服务器的xml(标准化越来越近了)字符串。它通过运行一个名叫initialize的存储过程,从服务器取回xml(标准化越来越近了)字符串,来查询clientcommands表的内容。

  clientcommands表包括两个域:command_name域和command_xml(标准化越来越近了)域。客户端程序需要三个特定的command_name域:getcustomerlist,custorderhist和recentpurchasebycustomerid。每一个命令的command_xml(标准化越来越近了)域包括程序发送到getdata.页面的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 = "https://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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网