473,396 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Returning a DataSet from a Web Services

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
Nov 17 '05 #1
2 1381
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 thedatabase.")> _
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 declaredit.

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 aninstance of an object

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

Thank you!
Scott
.

Nov 17 '05 #2
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 thedatabase.")> _
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 declaredit.

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 aninstance of an object

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

Thank you!
Scott
.

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: K Altsj? | last post by:
If passing a DataSet to a web method for update using ADO.NET and the update fails, the parameter list may get corrupt. The following code example consists of a Web Service and a consumer console...
2
by: Sumaira Ahmad | last post by:
Hi All My Web Service is returning a DataSet. I realized that we cannot return a DataReader.. Normally we can use a DataReader( when not using Web services) and access it as below to assign...
2
by: Tarren | last post by:
Hi: What would be some standard convention to follow when writing web services for return types for .NET only data types? I initially wrote my web service that returns some XML as...
8
by: Myron Marston | last post by:
For a WebService I am developing, I return a DataSet that contains a table listing Field Names and Field Values. The FieldValue column is given the type object becuase it can potentially contain...
5
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was...
1
by: J. Askey | last post by:
I am implementing a web service and thought it may be a good idea to return a more complex class (which I have called 'ServiceResponse') in order to wrap the original return value along with two...
0
by: TMesh | last post by:
Hello Is it possible to return a Crystal ReportDocument from a WebService? I keep getting the following error: Exception: System.Web.Services.Protocols.SoapException: Server was unable to...
2
by: Anthony Biondo Jr | last post by:
I am trying to figure out the best way to return data through a web service. If the value is a single value I can just set it equal to the web service name. If I am returning a set of data I have...
15
by: Joseph Geretz | last post by:
I'm a bit puzzled by the current recommendation not to send Datasets or Datatables between application tiers. http://support.microsoft.com/kb/306134 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.