Asp.net 通过重定向到Url进行处理
我后面有VB.net代码,如下所示:Asp.net 通过重定向到Url进行处理,asp.net,vb.net,web-services,response.redirect,Asp.net,Vb.net,Web Services,Response.redirect,我后面有VB.net代码,如下所示: Protected Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button.Click Dim Adapter As New SqlDataAdapter Dim sql As String = "select House , OPR_BALANCE from vAgeLast where LEN(HOUSE
Protected Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button.Click
Dim Adapter As New SqlDataAdapter
Dim sql As String = "select House , OPR_BALANCE from vAgeLast where LEN(HOUSE) = 8 and OPR_BALANCE > 1000000 order by OPR_BALANCE desc"
SqlConn.Open()
sqlCmd = New SqlCommand(sql, SqlConn)
Adapter.SelectCommand = sqlCmd
Adapter.Fill(ds)
For i = 0 To ds.Tables(0).Rows.Count - 1
idCustomer = ds.Tables(0).Rows(i)("House").ToString()
amt = ds.Tables(0).Rows(i)("OPR_BALANCE").ToString()
lang = "0"
aid = "000000"
Dim result As String = "http://soap.Services.com:2121/WS.aspx/?c=1&id=" + idCustomer + "&lang=" + lang + ""
Response.Redirect(result)
Next
Adapter.Dispose()
sqlCmd.Dispose()
SqlConn.Close()
End Sub
在这段代码中,我想处理dataset结果中的所有值,这只能通过重定向到url获得,但当我运行代码时,它只运行一次
是否可以重定向到url而不在网站上显示反馈?尝试添加“Dim SqlConn As New SQLConnection”我从其他用户那里得到的 在循环内重定向将不起作用。你需要用另一种方式呼叫服务。 尝试使用
WebClient
的DownloadString
方法。通过以下方式提取结果
:
Dim client As New WebClient()
Dim result As String = client.DownloadString("http://soap.Services.com:2121/WS.aspx/?c=1&id=" + idCustomer + "&lang=" + lang )
如果抛出异常,您将永远无法在sql连接上调用.Close()。如果这种情况经常发生,您可以将自己锁定在数据库之外。您需要一个Try/Finally或Using块。当我得到这一行时如何:Dim result As String=
“http://soap.Services.com:2121/WS.aspx/?c=1&id=“+idCustomer+”&lang=“+lang+”响应。重定向(结果)
是否可能响应。重定向执行多次?响应。重定向()停止当前页面并将您发送到新页面。如果你有20条记录,你希望结果是什么?在用户浏览器中打开了20个选项卡?当我得到这一行时如何:Dim result As String=“http://soap.Services.com:2121/WS.aspx/?c=1&id=“+idCustomer+”&lang=“+lang+”响应。重定向(结果)
是否可能响应。重定向执行多次?