Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
| Search | Today's Posts | Mark Forums Read
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 28th, 2005, 02:24 AM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
  #2 (permalink)  
Old March 1st, 2005, 10:01 AM
Authorized User
 
Join Date: Nov 2004
Location: Indore, MP, India.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to avanishp
Default

Can you post the code ...

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

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.
  #4 (permalink)  
Old March 2nd, 2005, 03:25 AM
Authorized User
 
Join Date: Nov 2004
Location: Indore, MP, India.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to avanishp
Default

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



  #5 (permalink)  
Old March 13th, 2006, 05:43 PM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

        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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Method Returning a complex Custom data type. saisunil1978 .NET Web Services 0 July 15th, 2008 05:38 AM
How to use global dataset for asp.net application swati_joshi ASP.NET 1.0 and 1.1 Basics 3 April 6th, 2007 09:30 PM
Returning resultset to ADO.NET dataset gp_mk Oracle 3 December 22nd, 2003 10:44 AM
Returning Oracle SELECT query results to DataSet gp_mk ADO.NET 0 December 17th, 2003 11:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.