Results 1 to 6 of 6

Thread: vb2013 - Trying to retrieve data from a web service and display in datagrid view

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2014
    Posts
    3

    vb2013 - Trying to retrieve data from a web service and display in datagrid view

    Hi
    I currently have a working web service. I'am trying to access the web service to display product data for various clients through the use of a datagrid. I wish to use a button to display all the clients and their product information into a datagrid however I don't now the specific code to do this any help thanks.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: vb2013 - Trying to retrieve data from a web service and display in datagrid view

    We don't know the code either because we don't know anything about your web service or your data. What I can tell you though is that, once you have added the service reference to your project, calling a web method is basically the same as calling any other method. Do you know how to add a service reference to your project? If not then that is what you should look into.

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2014
    Posts
    3

    Re: vb2013 - Trying to retrieve data from a web service and display in datagrid view

    Well the data is in xml format in the web service so : Client ID, Name, Product name etc its in nodes not in a data set or anything like that..I'am trying to use a button to call the service then put that data into a datagrid is what I'm struggling with I do have a web reference in place and works I can call the service with code like:
    Code:
    Private Sub Get btnClient_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetClient.Click
    Dim ClientID As String
    MessageBox.Show(service.GetProduct("121"))
    Which returns the client with the id of 121 but how can I place this into my datagrid which i have named "dgClient" thanks for the reply

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: vb2013 - Trying to retrieve data from a web service and display in datagrid view

    Quote Originally Posted by voxterx View Post
    I do have a web reference in place and works I can call the service with code
    It's generally a good idea to explain that upfront as we can only know what you tell us.
    Quote Originally Posted by voxterx View Post
    Which returns the client with the id of 121 but how can I place this into my datagrid which i have named "dgClient" thanks for the reply
    What EXACTLY do you get back from that GetProduct method?

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2014
    Posts
    3

    Re: vb2013 - Trying to retrieve data from a web service and display in datagrid view

    Ok here is what I want this client application to be able to do. I want a button to be able to access the webservice I have created which has the following xml as an example:

    Code:
    </Product>
      <Product>
        <Client ID="134">
          <Name>Sterling Stamper</Name>
          <Product Name="Seagate 1TB Expansion Portable Hard Drive">
            <ProductBrand>Seagate</ProductBrand>
            <ProductCapacity>1TB</ProductCapacity>
            <ProductPrice>47.84</ProductPrice>
          </Product>
        </Client>
      </Product>
    The button will be used to display the clientID with the above data into a datagrid view I have the following code so far:


    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetClient.Click
            
            Dim ClientID As String = InputBox("Enter the Client ID")
            If ClientID <> ClientID Then
                ClientID =
                My.Settings("ClientID") = ClientID
                If service.GetProduct(ClientID) Then
                    MessageBox.Show("Here is the current Client")
                Else
                    MessageBox.Show("Client Changed")
                End If
            End If
            getProducts()
            displayList()
    
        End Sub
    When the code is run I get an input box where I would put in the clientID but I get an error like this:

    Name:  qwq.jpg
Views: 80
Size:  19.7 KB

    What i want is the button to be clicked then enter the clientid in the input box then have it appear inside a datagridview do you know how i can do this in code?

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: vb2013 - Trying to retrieve data from a web service and display in datagrid view

    That error message is telling you that there's no web service available at the address you're sending the request to. Did you do as the Exception Assistant instructs and see the InnerException?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width