在vb 2010中使用Web服务

时间:2012-10-01 19:20:04

标签: vb.net visual-studio-2010 web-services

抱歉,自从我与MS Web服务客户合作以来已经有一段时间了。我正在使用Web开发人员2010.我创建了一个返回的Web方法:

-<NewDataSet xmlns=""> -<TC diffgr:id="TC1" msdata:rowOrder="0">
 <SalesN>25</SalesN> 
  <PctDiscount>0.0000</PctDiscount> 
   <SubDiscount>0.0000</SubDiscount> 
 </TC> 
<TC diffgr:id="TC2" msdata:rowOrder="1"/> 
 -<TC diffgr:id="TC3" msdata:rowOrder="2"> 
  <PctDiscount>0.0000</PctDiscount> 
   <SubDiscount>0.0000</SubDiscount> 
   <SalesT>685.89</SalesT> 
</TC>
...

我正在尝试查看SalesN和SalesT中的信息

我的aspx按钮点击如下:

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim date1 As String
    Dim date2 As String
    Dim myString As String
    date1 = TextBox1.Text
    date2 = TextBox2.Text

    Dim myreport As New ServiceReferenceReport.wsReportEngineSoapClient
    myreport.GetSalesTotals(date1, date2)
End Sub

有人可以指点我的教程,还是刷新我的记忆?

我已加载数据网格,似乎无法解析数据元素。

1 个答案:

答案 0 :(得分:0)

得到了......

    Dim date1 As String
    Dim date2 As String
    date1 = TextBox1.Text
    date2 = TextBox2.Text

    Dim returnds As New DataSet
    Dim myreport As New ServiceReferenceReport.wsReportEngineSoapClient
    returnds = myreport.GetSalesTotals(date1, date2)
    Dim i As Integer
    Dim current As String
    For i = 0 To returnds.Tables(0).Rows.Count - 1
        If IsDBNull(returnds.Tables(0).Rows(i)("SalesN")) = True Then
            current = ""
        Else
            current = CStr(returnds.Tables(0).Rows(i)("SalesN"))
            Label1.Text = current
        End If
        If IsDBNull(returnds.Tables(0).Rows(i)("SalesT")) = True Then
            current = ""
        Else
            current = CStr(returnds.Tables(0).Rows(i)("SalesT"))
            Label2.Text = current
        End If
    Next

End Sub