Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

web service: why does method expect object when sig calls for string?

Status
Not open for further replies.

bebblebrox

IS-IT--Management
Aug 9, 2004
39
US
Hi,

I have the following webservice:

Code:
Imports System.Web.Services
Imports System.Data.SqlClient
Imports System.Data

<System.Web.Services.WebService(Namespace:="com.catalystsolves.northwindCustomers")> _
Public Class Customers
    Inherits System.Web.Services.WebService

#Region " Web Services Designer Generated Code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Web Services Designer.
        InitializeComponent()

        'Add your own initialization code after the InitializeComponent() call

    End Sub

    'Required by the Web Services Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Web Services Designer
    'It can be modified using the Web Services Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        'CODEGEN: This procedure is required by the Web Services Designer
        'Do not modify it using the code editor.
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

#End Region

    <WebMethod()> Public Function getCustomers(ByVal country As String) As DataSet
        'fill the dataset
        Dim cnn As SqlConnection = New SqlConnection(cnnString)

        Dim cmd As SqlCommand = cnn.CreateCommand
        cmd.CommandType = CommandType.Text
        cmd.CommandText = "Select CompanyName from customers where " & _
                                        "country = '" & country & "'"

        Dim da As SqlDataAdapter = New SqlDataAdapter
        Dim ds As DataSet = New DataSet


        da.SelectCommand = cmd
        da.Fill(ds, "Customers")

        getCustomers = ds

    End Function



End Class

notice that the getCountry method takes a string. whenever i try to use this web service vs.net intellisense calles for an object as the parameter and if i try to use a string i get an invalid cast exception.

what gives?

thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top