Link to home
Create AccountLog in
Avatar of GlobaLevel
GlobaLevelFlag for United States of America

asked on

Web service ( 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
            Dim dsn As String = "server=<xx.xx.xx.xx>;database=<Tessdext>;uid=sa;pwd="
            Dim myconnection As SqlConnection = New SqlConnection(dsn)
            ' ---
            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")
            ' ---
            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")
            Return (ds_TO_NUM, ds_MSG)
        Catch ex As Exception
        End Try
    End Function
Avatar of leechoonhwee

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)

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

good ol' expert exchange huh !!!!

Merry christmas !!!
Avatar of BuggyCoder
Flag of India image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Amandeep Singh Bhullar
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
            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
            Return ds_MSG
        End Get
        Set(ByVal value As DataSet)
            ds_MSG = value
        End Set
    End Property
End Class

Open in new window