View Single Post
  #3 (permalink)  
Old March 2nd, 2005, 02:41 AM
niravpatel niravpatel is offline
Registered User
Join Date: Feb 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Here is my code of web service whcih returns dataset from a database.
It displays well in the window applicaiton with datagrid but no idea y it is not displaying in web application. Code is remains same in both web application & window client.

Web Service Code

<WebMethod()> _
    Public Function GetTableData() As DataSet
        Dim dsn As String = "server=server;database=db;uid=user;pwd=passwo rd"
        Dim myConn As SqlClient.SqlConnection = New SqlClient.SqlConnection(dsn)
        'Open database connection
        'Fetch data from database
        Dim myComm As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter("select Name from BillTo where Bill_ID < 10", myConn)
        Dim ds As DataSet = New DataSet
        'Fill dataset with records
        myComm.Fill(ds, "Name")
        'Dim dataTable As New DataTable
        'dataTable = ds.Tables(1)
        'Close the connection
        'Return dataset
        Return ds 'dataset
        ds = Nothing
    End Function

Window Application Client code works fine

Private Sub btnGetData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetData.Click
        Dim ds As New DataSet
        Dim service As New localhost.Service1
        ds = service.GetTableData()
        DataGrid1.DataSource = ds.Tables(0)
    End Sub

Web Application client code...Not working

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
         Dim ds As New DataSet
        Dim WService As New localhost.Service1
            ds = WService.GetTableData()
            DataGrid1.DataSource = ds.Tables(0)
        Catch ex As Exception
            Label1.Text = ex.Message
        End Try
End Sub

Plesase help..
Thanx in advance.

Nirav Patel.