Click here to Skip to main content
12,691,777 members (28,595 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB VB.NET WebService
Hi, its me again.
I wanted to ask on <u>How to use (pass and return) array in function?</u>
I have this code on my Webservice project

WebMethod() _
      Public Function InsertProduk(ByVal key As Array, ByVal val As String, ByVal konter As Integer) As DataSet
        Dim conn As String
        Dim i As Integer = konter
        For a As Integer = 0 To i
            conn = &quot;server=localhost;uid=root;pwd=;database=miles&quot;
            Dim sql As String = &quot;insert into trade set id_pro="' + key(i) + '";
            Dim konek As New MySqlConnection(conn)
            Dim OdbcDa As New MySqlDataAdapter(Sql, conn)
            Dim ds As New DataSet
            Return ds
    End Function

This is what I imports in my webservice
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Data
Imports MySql.Data
Imports MySql.Data.MySqlClient
Imports MySql.Web
Imports MySql.Web.SessionState

But when I tr=ied to browse it, system throws me this error :
You must implement a default accessor on System.Array because it inherits from ICollection.
Posted 16-Jun-11 22:56pm
Updated 16-Jun-11 23:20pm
SAKryukov 17-Jun-11 4:00am
In what line of code?
satrio_budidharmawan 17-Jun-11 4:19am
What do you mean with "what line code"?
thatraja 17-Jun-11 5:32am
SA asked, "which line you are getting the error?"

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Your error is to do with the type of object that you are passing to your webservice. VB.NET is rather particular in what you can pass to it. I would have a look at this article

You must implement a default accessor on System.Array b...[^]

It would appear that you need to change the array to a generic list, there is an example of this in the article. Also to return a true dataset you will need to change

 Return ds

to, as the above will return a Diffgram[^]

 return ctype(ds, dataset)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170117.1 | Last Updated 17 Jun 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100