p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   .NET Web Services (http://p2p.wrox.com/net-web-services-102/)
-   -   Returning dataset to web application (http://p2p.wrox.com/net-web-services/26169-returning-dataset-web-application.html)

niravpatel February 28th, 2005 02:24 AM

Returning dataset to web application
 

Hi Everybody,
I m new in developing web service in vb.net. I have web service that returns dataset as results from database. When i call web service in window application it displays me result in the datagrid, but with the web application i m not been able to display the result from the web service.

What should i do??
Pls help me...

Cheers,
Nirav Patel.

avanishp March 1st, 2005 10:01 AM

Can you post the code ...


niravpatel March 2nd, 2005 02:41 AM

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
        myConn.Open()
        '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
        myConn.Close()
        '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
        Try
            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.

Cheers,
Nirav Patel.

avanishp March 2nd, 2005 03:25 AM

use databind at last
Try
            ds = WService.GetTableData()
            DataGrid1.DataSource = ds.Tables(0)
            DataGrid1.DataBind()
        Catch ex As Exception
            Label1.Text = ex.Message
        End Try




jpbisguier March 13th, 2006 05:43 PM

        Return ds 'dataset
        ds = Nothing <- you may also want to put this at the top or something seeing as your function exits before this is executed
End Function





All times are GMT -4. The time now is 08:58 AM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.