Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Newbie Question: fill a dataset with results from web service call

Reply
Thread Tools

Newbie Question: fill a dataset with results from web service call

 
 
Todd
Guest
Posts: n/a
 
      01-08-2004
I am trying to get a better grasp of using web services. I have had
success when I have a user type something into a text box and then
pass that text to call an external web service on another server.
This has worked for me when the result was only a single word such as
"true" or "false". Now, I would like to make a call to a service that
returns either rows of data or more than one word, such as a stock
symbol returning the price, high, low, estimates, rating, etc. How
would I make the call to the external web service and then assign the
results to a Dataset? I want to use this dataset as the datasource
for a Data Grid to display on the screen. Or perhaps there is an
easier way to do this?
 
Reply With Quote
 
 
 
 
Michael Pearson
Guest
Posts: n/a
 
      01-08-2004
The "easier" way to do this is to just avoid the webservice piece and call
the database code directly.
For a webservice, it should be as simple as making your WebMethod() return a
Dataset type.

VB.Net Example

<WebMethod()> Public Function GetListOfSomething(ByVal sParamBlah As String)
As DataSet

Dim myDataSet as New DataSet()

'Insert Code here to connect to database and populate a myDataSet

Return myDataset
End Function

Michael
"Todd" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> I am trying to get a better grasp of using web services. I have had
> success when I have a user type something into a text box and then
> pass that text to call an external web service on another server.
> This has worked for me when the result was only a single word such as
> "true" or "false". Now, I would like to make a call to a service that
> returns either rows of data or more than one word, such as a stock
> symbol returning the price, high, low, estimates, rating, etc. How
> would I make the call to the external web service and then assign the
> results to a Dataset? I want to use this dataset as the datasource
> for a Data Grid to display on the screen. Or perhaps there is an
> easier way to do this?



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.559 / Virus Database: 351 - Release Date: 1/7/2004


 
Reply With Quote
 
 
 
 
Todd
Guest
Posts: n/a
 
      01-09-2004
Thanks Michael. I understand what you are talking about as I have
used the Command object several times to use a sql call or stored
procedure call to populate a Dataset and display the information in a
DataList or DataGrid. However, the purpose of calling the web service
is to access data that I can't get from my database. For example, if
I want to enter a stock symbol into a text box and press a submit
button, I can't pass that sysmbol to a table on my database because I
am not housing current data for stock prices. But there are several
external web services that will do this. I just need to know the
VB.Net syntax "from A to Z" on how I would return the web service
result set into a dataset to bind to a datagrid. I have added my Web
Reference for the stock price web service to my project, and I am
passing the symbol to the service. I just need help on how I would be
able to return the results to a DataGrid to display to the user.

I have had success using an e-mail validator with this syntax:
dim proxyEmail as new [Project
Name].refernce.path.to.external.web.service
Label.Text = proxyEmail.[webservice_name](textbox1.text)

this returns either "true" or "false" to a label that is displayed to
the user. Now if I want to return more data from a more complicated
web service and bind that to a Datagrid to display to a user how would
I do that? Do I use a Dataset control? An XMLDataDocument? Something
else? Syntax examples would be appreciated. Thanks!

"Michael Pearson" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> The "easier" way to do this is to just avoid the webservice piece and call
> the database code directly.
> For a webservice, it should be as simple as making your WebMethod() return a
> Dataset type.
>
> VB.Net Example
>
> <WebMethod()> Public Function GetListOfSomething(ByVal sParamBlah As String)
> As DataSet
>
> Dim myDataSet as New DataSet()
>
> 'Insert Code here to connect to database and populate a myDataSet
>
> Return myDataset
> End Function
>
> Michael

 
Reply With Quote
 
Dino Chiesa [Microsoft]
Guest
Posts: n/a
 
      01-09-2004
have you looked at the DataSet.Merge() method ?
Maybe you get ds1 from webservice1, then get ds2 from webservice2, then
merge them, then display?
-D

"Todd" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Thanks Michael. I understand what you are talking about as I have
> used the Command object several times to use a sql call or stored
> procedure call to populate a Dataset and display the information in a
> DataList or DataGrid. However, the purpose of calling the web service
> is to access data that I can't get from my database. For example, if
> I want to enter a stock symbol into a text box and press a submit
> button, I can't pass that sysmbol to a table on my database because I
> am not housing current data for stock prices. But there are several
> external web services that will do this. I just need to know the
> VB.Net syntax "from A to Z" on how I would return the web service
> result set into a dataset to bind to a datagrid. I have added my Web
> Reference for the stock price web service to my project, and I am
> passing the symbol to the service. I just need help on how I would be
> able to return the results to a DataGrid to display to the user.
>
> I have had success using an e-mail validator with this syntax:
> dim proxyEmail as new [Project
> Name].refernce.path.to.external.web.service
> Label.Text = proxyEmail.[webservice_name](textbox1.text)
>
> this returns either "true" or "false" to a label that is displayed to
> the user. Now if I want to return more data from a more complicated
> web service and bind that to a Datagrid to display to a user how would
> I do that? Do I use a Dataset control? An XMLDataDocument? Something
> else? Syntax examples would be appreciated. Thanks!
>
> "Michael Pearson" <(E-Mail Removed)> wrote in

message news:<(E-Mail Removed)>...
> > The "easier" way to do this is to just avoid the webservice piece and

call
> > the database code directly.
> > For a webservice, it should be as simple as making your WebMethod()

return a
> > Dataset type.
> >
> > VB.Net Example
> >
> > <WebMethod()> Public Function GetListOfSomething(ByVal sParamBlah As

String)
> > As DataSet
> >
> > Dim myDataSet as New DataSet()
> >
> > 'Insert Code here to connect to database and populate a myDataSet
> >
> > Return myDataset
> > End Function
> >
> > Michael



 
Reply With Quote
 
Michael Pearson
Guest
Posts: n/a
 
      01-09-2004
Oh, I see. You are getting like some Text or Array types back, and you want
to "build your own" dataset.

Take a look at this site:
http://www.informit.com/isapi/produc...tent/index.asp

I used that to build this small sample

Dim oDataSet As New DataSet()

Dim oTable As New DataTable()

Dim oRow As DataRow

Dim oStock(1) As Object

oTable.Columns.Add("StockSymbol", GetType(String))

oTable.Columns.Add("StockPrice", GetType(String))



oStock(0) = "BLAH"

oStock(1) = "$3.50"

oTable.Rows.Add(oStock)

oStock(0) = "BLAH2"

oStock(1) = "$6.00"

oTable.Rows.Add(oStock)



oDataSet.Tables.Add(oTable)

Michael



"Todd" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Thanks Michael. I understand what you are talking about as I have
> used the Command object several times to use a sql call or stored
> procedure call to populate a Dataset and display the information in a
> DataList or DataGrid. However, the purpose of calling the web service
> is to access data that I can't get from my database. For example, if
> I want to enter a stock symbol into a text box and press a submit
> button, I can't pass that sysmbol to a table on my database because I
> am not housing current data for stock prices. But there are several
> external web services that will do this. I just need to know the
> VB.Net syntax "from A to Z" on how I would return the web service
> result set into a dataset to bind to a datagrid. I have added my Web
> Reference for the stock price web service to my project, and I am
> passing the symbol to the service. I just need help on how I would be
> able to return the results to a DataGrid to display to the user.
>
> I have had success using an e-mail validator with this syntax:
> dim proxyEmail as new [Project
> Name].refernce.path.to.external.web.service
> Label.Text = proxyEmail.[webservice_name](textbox1.text)
>
> this returns either "true" or "false" to a label that is displayed to
> the user. Now if I want to return more data from a more complicated
> web service and bind that to a Datagrid to display to a user how would
> I do that? Do I use a Dataset control? An XMLDataDocument? Something
> else? Syntax examples would be appreciated. Thanks!
>
> "Michael Pearson" <(E-Mail Removed)> wrote in

message news:<(E-Mail Removed)>...
> > The "easier" way to do this is to just avoid the webservice piece and

call
> > the database code directly.
> > For a webservice, it should be as simple as making your WebMethod()

return a
> > Dataset type.
> >
> > VB.Net Example
> >
> > <WebMethod()> Public Function GetListOfSomething(ByVal sParamBlah As

String)
> > As DataSet
> >
> > Dim myDataSet as New DataSet()
> >
> > 'Insert Code here to connect to database and populate a myDataSet
> >
> > Return myDataset
> > End Function
> >
> > Michael



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.559 / Virus Database: 351 - Release Date: 1/7/2004


 
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
Using ajax call to fetch multiple results from multiple queries and showing them 1 by 1 as the results comes. Biranchi Narayan Panda ASP .Net 0 02-21-2010 03:46 PM
How can I make this more efficient? (combining DataSet results with the results of a DB lookup.) Ken Fine ASP .Net 3 07-23-2008 08:11 AM
'web service call failed: 500' using ajax hovermenu and web service Not Me ASP .Net 1 06-05-2007 03:09 PM
InvocationTargetException when calling "new Service()" in Axis web service to call another web service Michael Averstegge Java 0 01-10-2006 11:05 PM
Newbie question: Fill dataset will ALL tables from database Pierre van Rooyen ASP .Net 3 05-21-2004 07:43 AM



Advertisments