首页 | 培训 | 求学 | 参考 | 教师 | 教材 | 学校 | 招聘 | 租房 | 旅游ASKEDU.com  


培训指南—ASKEDU.com

返回 | 主页


使用ASP、VB和XML建立运行于互联网上的应用程序5



[摘要]
Function getCommandXML(command_name As String) As String
   RCommands.MoveFirst
   RCommands.Find "command_name=’" & command_name & "’", , adSearchForward, 1
...

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


其它培训参考信息:
使用ASP、VB和XML建立运行于互联网上的应用程序4
使用ASP、VB和XML建立运行于互联网上的应用程序3
使用ASP、VB和XML建立运行于互联网上的应用程序2
使用ASP、VB和XML建立运行于互联网上的应用程序1
浅谈数据库的攻击(数据库扫描工具)
浅谈数据库的攻击(数据库里如何留后门)
浅谈数据库的攻击(数据库的利用)
浅谈数据库的攻击(4)



信息来自互联网,敬请核实,谨慎使用



 




  中国 | Worldwide: United States United Kingdom Australia Canada India | Travel AgencyASKEDU.com