本文介绍了如何在Webservice VB.NET中将数组作为函数参数传递?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

又是我.
我想问< u>如何在函数中使用(传递和返回)数组?</u>
我的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)
            konek.Open()
            Dim ds As New DataSet
            OdbcDa.Fill(ds)
            konek.Close()
            Return ds
        Next
    End Function


这就是我在Web服务中导入的内容


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


但是当我尝试浏览它时,系统抛出此错误:
您必须在System.Array上实现默认访问器,因为它继承自ICollection.


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.

推荐答案

Return ds



,因为上面将返回 Diffgram [ ^ ]



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

return ctype(ds, dataset)


这篇关于如何在Webservice VB.NET中将数组作为函数参数传递?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 14:54