-
Aug 28th, 2015, 04:35 AM
#1
Thread Starter
Junior Member
[RESOLVED] [Help] returning an SqlDataReader in WCF Service ASP.NET-VB
i have a WCF web service that have a function named "GetData" returning a SQLDataReader type.
the problem is when i try to access "GetData" function from my code, i get compiler error Value of type '1-dimensional array of Object' cannot be converted to 'System.Data.SqlClient.SqlDataReader'.
this is really frustrating me. anyone please help me. thanks, before. really appreciate it.
-
Aug 28th, 2015, 03:50 PM
#2
Re: [Help] returning an SqlDataReader in WCF Service ASP.NET-VB
It has been a while since I did any web service work, but if I remember right, the web service can't return complex object types like a SQLDataReader, only objects that can be serialized in order to be transported across the webservice. You can create a dataset object that you fill with record data on the ASP.NET side of things and pass that over the web service, since dataset objects can be serialized.
-
Aug 28th, 2015, 08:19 PM
#3
Thread Starter
Junior Member
Re: [Help] returning an SqlDataReader in WCF Service ASP.NET-VB
Originally Posted by kleinma
It has been a while since I did any web service work, but if I remember right, the web service can't return complex object types like a SQLDataReader, only objects that can be serialized in order to be transported across the webservice. You can create a dataset object that you fill with record data on the ASP.NET side of things and pass that over the web service, since dataset objects can be serialized.
that's what i thought too, but i have to make sure to myself. i can call the function in wcf service when i use a dataset. weel i guess i'll use your advice.
but i wonder if i can pass my own class as a return value. is it possible?
p.s. i'm sorry for my english so poor
-
Aug 29th, 2015, 02:35 AM
#4
Re: [Help] returning an SqlDataReader in WCF Service ASP.NET-VB
A data reader is an object that executes a query and then provides access to the result set created by the database. Each time you call Read, it reads a record from the database. If your web service was to return a data reader, how could the client expect to call Read and get a record from the database? As kleinma says, you need to execute the query and retrieve the entire result set and package that up and return it. That would mean calling Load on your data reader and populating a DataTable or else using a data adapter to populate a DataTable. You can then return the DataTable as is or as part of a DataSet.
-
Aug 31st, 2015, 03:56 AM
#5
Thread Starter
Junior Member
Re: [RESOLVED] [Help] returning an SqlDataReader in WCF Service ASP.NET-VB
thanks for the help. i decided to use the dataset. thank you very much guys
-
Aug 31st, 2015, 06:30 AM
#6
Re: [RESOLVED] [Help] returning an SqlDataReader in WCF Service ASP.NET-VB
If I may - If all you are going to return is a single table, I'd suggest using a DataTable, less over head. I'd only use a DataSet if you were returning more than one tble in a single call.
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|