Web service (vb.net) to return multiple parameters

code is a little buggy at the return statement, how do I return multiple paramters?

<WebMethod()> Public Function GetCities(ByVal State As String) As DataSet
     
        Try
     
            Dim dsn As String = "server=<xx.xx.xx.xx>;database=<Tessdext>;uid=sa;pwd="
            Dim myconnection As SqlConnection = New SqlConnection(dsn)
            myconnection.Open()
            ' ---
            Dim mycommand_TO_NUM As SqlDataAdapter = New SqlDataAdapter("select TO_NUMBER from message_queue ", myconnection)
            Dim ds_TO_NUM As New DataSet()
            mycommand_TO_NUM.Fill(ds_TO_NUM, "TO_NUMBER")
            myconnection.Close()
       
            ' ---
       
            Dim mycommand_MSG As SqlDataAdapter = New SqlDataAdapter("select MESSAGE from message_queue ", myconnection)
            Dim ds_MSG As New DataSet()
            mycommand_MSG.Fill(ds_MSG, "MESSAGE")
            myconnection.Close()
       
            Return (ds_TO_NUM, ds_MSG)
           
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Function
LVL 10
GlobaLevelProgrammerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leechoonhweeCommented:
Is this what you are looking for? Using one sql statement to return 2 columns?

Dim mycommand_TO_NUM As SqlDataAdapter = New SqlDataAdapter("select TO_NUMBER, Message from message_queue ", myconnection)
Wardy_01Commented:

Well im guessing this is what you're looking for ...

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_20989347.html

good ol' expert exchange huh !!!!

Merry christmas !!!
BuggyCoderCommented:
please check the code.
also please go through the following MSDN link, it might help you learn more about return Dataset, Datatables from web service
http://support.microsoft.com/kb/306134



<WebMethod()> Public Function GetCities(ByVal State As String) As DataSet
      
        Try
      
            Dim dsn As String = "server=<xx.xx.xx.xx>;database=<Tessdext>;uid=sa;pwd="
            Dim myconnection As SqlConnection = New SqlConnection(dsn)
            myconnection.Open()
            ' ---
            Dim mycommand_TO_NUM As SqlDataAdapter = New SqlDataAdapter("select TO_NUMBER from message_queue ", myconnection)
            'Dim ds_TO_NUM As New DataSet()
Dim dt_TO_NUM As New DataTable()
            mycommand_TO_NUM.Fill(dt_TO_NUM, "TO_NUMBER")
            myconnection.Close()
        
            ' ---
        
            Dim mycommand_MSG As SqlDataAdapter = New SqlDataAdapter("select MESSAGE from message_queue ", myconnection)
'Dim ds_MSG As New DataSet()
Dim dt_MSG As New DataTable()
            mycommand_MSG.Fill(ds_MSG, "MESSAGE")
            myconnection.Close()
        
            DataSet dsRet=new DataSet();
            dsRet.Tables.Add(dt_TO_NUM)
            dsRet.Tables.Add(dt_MSG)

            return dsRet;
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Function

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Amandeep Singh BhullarCommented:
You are sending two dataSets from the function namely "ds_TO_NUM" and "ds_MSG"

Whch is simply not possible.
Best solution is to create the response type obect with two properies as

Assign the values and return it to calling function
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Runtime.Serialization

<DataContract()> _
Public Class GetCitiesResponse
    Private ds_TO_NUM As DataSet
    Private ds_MSG As DataSet

    <DataMember()> _
    Public Property TO_NUM() As DataSet
        Get
            Return ds_TO_NUM
        End Get
        Set(ByVal value As DataSet)
            ds_TO_NUM = value
        End Set
    End Property

    <DataMember()> _
    Private Property MSG() As DataSet
        Get
            Return ds_MSG
        End Get
        Set(ByVal value As DataSet)
            ds_MSG = value
        End Set
    End Property
End Class

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.