Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Returning a DataSet from a Web Services

Reply
Thread Tools

Returning a DataSet from a Web Services

 
 
Boffo Jinko
Guest
Posts: n/a
 
      11-07-2003
This should be obvious, but I can't figure it out...

I have the following web service:

<WebMethod (Description:="Returns a dataset of all people from the
database.")> _
Public Function GetAllPeople() As DataSet

Dim objConn As New OleDbConnection(Application("dbString"))
Dim cmd As New OleDbCommand("persondata.all_people", objConn)
cmd.CommandType = CommandType.StoredProcedure
Dim da As New OleDbDataAdapter(cmd)
Dim dsTemp As New DataSet
objConn.Open()
da.Fill(dsTemp, "AllJudges")
Return dsTemp
End Function

From an ASP.NET project, I have referenced the web service and have declared
it.

Private objPeopleService As MyService.Service1
...
objPeopleService = New MyService.Service1
Dim objDs As DataSet = objPeopleService.GetAllPeople
Response.Write("<br>Count is " &
objDs.Tables("Exchanges").Rows.Count)

The Reponse.Write() line gives an error: Object reference not set to an
instance of an object

If I call a WebMethod that returns an integer, it returns fine. I created a
test WebMethod that gets a DataSet and then returns the count from the
WebMethod, as opposed to passing the DataSet back to the client, and it
returns the count just fine. So it looks like I am doing something wrong
either in the WebMethod Return statement or in assigning the DataSet a value
in the client. Any ideas about what the problem is?

Thank you!
Scott


 
Reply With Quote
 
 
 
 
Kaustav Neogy
Guest
Posts: n/a
 
      11-07-2003
Hi Scott,

try this -

Dim objDs As New DataSet()
objDs = objPeopleService.GetAllPeople

Kaustav Neogy.



>-----Original Message-----
>This should be obvious, but I can't figure it out...
>
>I have the following web service:
>
> <WebMethod (Description:="Returns a dataset of all

people from the
>database.")> _
>Public Function GetAllPeople() As DataSet
>
> Dim objConn As New OleDbConnection(Application

("dbString"))
> Dim cmd As New OleDbCommand

("persondata.all_people", objConn)
> cmd.CommandType = CommandType.StoredProcedure
> Dim da As New OleDbDataAdapter(cmd)
> Dim dsTemp As New DataSet
> objConn.Open()
> da.Fill(dsTemp, "AllJudges")
> Return dsTemp
> End Function
>
>From an ASP.NET project, I have referenced the web

service and have declared
>it.
>
> Private objPeopleService As MyService.Service1
> ...
> objPeopleService = New MyService.Service1
> Dim objDs As DataSet =

objPeopleService.GetAllPeople
> Response.Write("<br>Count is " &
>objDs.Tables("Exchanges").Rows.Count)
>
>The Reponse.Write() line gives an error: Object reference

not set to an
>instance of an object
>
>If I call a WebMethod that returns an integer, it returns

fine. I created a
>test WebMethod that gets a DataSet and then returns the

count from the
>WebMethod, as opposed to passing the DataSet back to the

client, and it
>returns the count just fine. So it looks like I am doing

something wrong
>either in the WebMethod Return statement or in assigning

the DataSet a value
>in the client. Any ideas about what the problem is?
>
>Thank you!
>Scott
>
>
>.
>

 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      11-07-2003
The problem is that when you fill the dataset, you call
it "AllJudges" and when you try to get the count you are
trying to reference it by "Exchanges".

If you change the names so they match, your code should
work. Another way to make this work if you are expecting
only one table would be to use the index of the table.
In this case you would use... objDs.Tables(0).Rows.Count

Good Luck,

Keith


>-----Original Message-----
>This should be obvious, but I can't figure it out...
>
>I have the following web service:
>
> <WebMethod (Description:="Returns a dataset of all

people from the
>database.")> _
>Public Function GetAllPeople() As DataSet
>
> Dim objConn As New OleDbConnection(Application

("dbString"))
> Dim cmd As New OleDbCommand

("persondata.all_people", objConn)
> cmd.CommandType = CommandType.StoredProcedure
> Dim da As New OleDbDataAdapter(cmd)
> Dim dsTemp As New DataSet
> objConn.Open()
> da.Fill(dsTemp, "AllJudges")
> Return dsTemp
> End Function
>
>From an ASP.NET project, I have referenced the web

service and have declared
>it.
>
> Private objPeopleService As MyService.Service1
> ...
> objPeopleService = New MyService.Service1
> Dim objDs As DataSet =

objPeopleService.GetAllPeople
> Response.Write("<br>Count is " &
>objDs.Tables("Exchanges").Rows.Count)
>
>The Reponse.Write() line gives an error: Object

reference not set to an
>instance of an object
>
>If I call a WebMethod that returns an integer, it

returns fine. I created a
>test WebMethod that gets a DataSet and then returns the

count from the
>WebMethod, as opposed to passing the DataSet back to the

client, and it
>returns the count just fine. So it looks like I am doing

something wrong
>either in the WebMethod Return statement or in assigning

the DataSet a value
>in the client. Any ideas about what the problem is?
>
>Thank you!
>Scott
>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How .NET web services client handles exceptions from Java web services? John ASP .Net Web Services 4 03-31-2006 10:13 PM
Please Help me- Returning DataSet from a Web Service Sumaira Ahmad ASP .Net Web Controls 1 11-03-2004 02:27 AM
Please Help me- Returning DataSet from a Web Service Sumaira Ahmad ASP .Net 2 11-02-2004 01:18 AM
Please Help me- Returning DataSet from a Web Service Sumaira Ahmad ASP .Net Datagrid Control 0 11-01-2004 09:23 PM
XML Web Service fails with System.InvalidOperationException returning a DataSet with RowErrors Curly ASP .Net Web Services 0 08-19-2003 07:11 AM



Advertisments