I'm trying to perform an Asynchronous call to a web service. The web service itself is a simple query, that returns a dataset, such as:

<WebMethod()> Public Function RetrieveSQL(ByVal sql As String) As DataSet
Dim cs As String = "data source=localhost;"
Dim cn As New System.Data.SqlClient.SqlConnection(cs)
Dim da As New System.Data.SqlClient.SqlDataAdapter(sql, cn)
Dim ds As New System.Data.DataSet()
da.Fill(ds)
Return ds
End Function

The client calls the web service, via two methods. One is Asynchronous, the other is Synchronous:

'TextBox1.Text contains the SQL statement to call

Private Sub AsyncCall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AsyncCall.Click
Dim ws As New localhost.Service1()
Dim cb As AsyncCallback = New AsyncCallback(AddressOf EndRetrieveSQL)
ws.BeginRetrieveSQL(TextBox1.Text, cb, ws)
End Sub

Private Sub EndRetrieveSQL(ByVal ar As System.IAsyncResult)
Dim ws As localhost.Service1 = ar.AsyncState
Dim ds As DataSet = ws.EndRetrieveSQL(ar)
DataGrid1.DataSource = ds.Tables(0)
End Sub

Private Sub SyncCall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SyncCall.Click
Dim ws As New localhost.Service1()
Dim ds As DataSet = ws.RetrieveSQL(TextBox1.Text)
DataGrid1.DataSource = ds.Tables(0)
End Sub

When I call it with the SyncCall button click, it returns the full dataset.
When I call it with the AsyncCall button click, it returns an empty dataset.

In the EndRetrieveSQL subroutine on the client, the first line
Dim ws As localhost.Service1 = ar.AsyncState
is wrong.
I know that the error to my code is in the client callback subroutine EndRetrieveSQL. How do I get this to work?

Samwise