我在VB.NET中设置了一个WCF,我试图让一个函数返回一个数组。 这样做不对!我尝试了很多东西并且搜索了很多东西。
所以错误是:
我在WCF中的功能:
Public Function GetCL_Contacts(ByVal cl_ID As Integer) As String() Implements SQLOperator.GetCL_Contacts
Dim Contacts() As String
Contacts = {}
Try
SQLCon.ConnectionString = SQLConString
SQLCon.Open()
SQLCMD = New SqlCommand("Select Nome from dbo.cl_contact Where cl_ID=" & cl_ID & " ORDER BY ID ASC;", SQLCon)
SQLDataReader = SQLCMD.ExecuteReader()
Dim I As Integer = 0
While SQLDataReader.Read
Contacts(I) = SQLDataReader("Nome")
I = I + 1
End While
Catch ex As Exception
MsgBox("Erro: " & Environment.NewLine & ex.ToString)
Finally
SQLCon.Close()
SQLCon.Dispose()
End Try
Return Contacts
End Function
我如何尝试使用该功能:
'Load Contacts
Dim Contacts() As String
Contacts = {}
Contacts = Service.GetCL_Contacts(clBox.SelectedIndex + 1)
For Each contact As String In Contacts
BoxCl_Contacts.Items.Add(contact)
Next
我是如何尝试解决此问题(并完全失败):
以上都没有奏效!