Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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
 
Old May 18th, 2004, 10:49 AM
Registered User
 
Join Date: May 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to raheelhussain Send a message via Yahoo to raheelhussain
Default Returning a dataset from a webservice

hi

i got a problem here in returning a Dataset from a webservice.

following is my code


in webservice
------------------------
Code:
<WebMethod()> _
Public Function GetDS(ByVal str As String) As System.Data.DataSet
    'code here
    cn.Open() 'connection object
    Dim cmd As New SqlCommand
        cmd.Connection = cn
        cmd.CommandType = System.Data.CommandType.Text
        Dim ds As New System.Data.DataSet
    Dim da As New SqlDataAdapter(cmd)
        da.SelectCommand = cmd
    cmd.CommandText = "select * from Emp where sName='"&str&"'"
        da.Fill(ds, "tblVehicle")
    return ds
End Function

and here how i m calling it
-----------------------------
Code:
Dim ds As System.Data.DataSet
ds = objWebService.GetDS("test")
I also tried calling it as
Code:
Dim ds As System.Data.DataSet=objWebService.GetDS("test")
things to note here is

- when i run the webservie in debug mode (through http://localhost/myservice.asmx)
  this functions works fine and return the dataset as xml document.

- when i copy the function in my consumer application (the asp.net web application)
  it works fine as a local function and returns dataset.

- but when i call it through my consumer web application through the webservice obj
  it gives me the following error :
Code:
  "object reference not set to an instance of object."
I require the help of you guys to sort out this.

best regards

With Best Regards
Raheel Hussain
 
Old May 23rd, 2004, 06:40 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

This is a common oversight (I do it often myself). You have to instantiate the web service proxy class:

Dim objWebService As New MyWebService.WebService
Dim ds As System.Data.DataSet
ds = objWebService.GetDS("test")


Peter
-------------------------
Work smarter, not harder





Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting a untyped dataset to a typed dataset daphnean Visual Studio 2005 0 July 13th, 2006 01:16 AM
Returning dataset to web application niravpatel .NET Web Services 4 March 13th, 2006 05:43 PM
Re: SQL Server dataset to ACCESS dataset dazzer ADO.NET 0 March 22nd, 2004 05:28 AM
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.