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

Discussion in 'ASP .Net Web Services' started by Todd, Jan 8, 2004.

  1. Todd

    Todd Guest

    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?
    Todd, Jan 8, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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
    Michael Pearson, Jan 8, 2004
    #2
    1. Advertising

  3. Todd

    Todd Guest

    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" <> wrote in message news:<>...
    > 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, Jan 9, 2004
    #3
  4. 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" <> wrote in message
    news:...
    > 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" <> wrote in

    message news:<>...
    > > 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
    Dino Chiesa [Microsoft], Jan 9, 2004
    #4
  5. 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/product_id~{6A3BC7D8-47B7-4C4B-BBDF-5B20CBC985F6}/content/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" <> wrote in message
    news:...
    > 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" <> wrote in

    message news:<>...
    > > 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
    Michael Pearson, Jan 9, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tim R.

    web service newbie dataset question

    Tim R., Jan 7, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    380
    Kevin Spencer
    Jan 7, 2004
  2. Pierre van Rooyen
    Replies:
    3
    Views:
    543
    Cor Ligthert
    May 21, 2004
  3. Michael Averstegge
    Replies:
    0
    Views:
    4,217
    Michael Averstegge
    Jan 10, 2006
  4. Ken Fine
    Replies:
    3
    Views:
    528
    Steven Cheng [MSFT]
    Jul 23, 2008
  5. Tim R.

    web service newbie dataset question

    Tim R., Jan 7, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    118
    Tim R.
    Jan 7, 2004
Loading...

Share This Page