We help IT Professionals succeed at work.
Get Started

return multiple value in webservices in vb.net

Bakersville asked
Last Modified: 2012-05-09
Hello everyone.

Been working on this for about 2 weeks now and done some things great, but can't get it to do above.

I have created a web service that will insert any data i want into a sql database, however, when i try and retreive data from the database using what i know, i only get the last record rather than all 20 records returning.

So, i thought i would be clever and get it to return the value everytime it loop through the records, however, it only bring up the first record, not the last.

Can any help me try and get it to display all 20 records when i involke the service. From there, i should be able to display it in another application.

Code below

Thank you in advance
Imports System.Web.Services
Imports System.Data.SqlClient

<WebService(Namespace:="http://website.co.uk/")> Public Class TeamList

#Region " Web Services Designer Generated Code"

#End Region

    <WebMethod()> Public Function TeamDisplay()

        'Connect to DB and get the XML code for the teams

        Dim conn As SqlConnection
        conn = New SqlConnection("Data Source=localhost;Initial Catalog=DatabaseTest;Persist Security Info=True;User ID=user;Password=password")

        Dim cmd As SqlCommand

        cmd = New SqlCommand("select Team from CalenderTeam", conn)

            Dim rdr As SqlDataReader
            rdr = cmd.ExecuteReader

            If rdr.HasRows Then

                While rdr.Read()

                    Return Display1

                End While


            End If

        End Try

    End Function

End Class

Open in new window

Watch Question
Software Architect
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE