Answered by:
how to pass list of string to a webservice Please help.

Question
-
User2089553522 posted
hello guys im trying to do something that should be pretty simple but i guess i have over compilcated things. here is the code. i basicall want to field an array of items and then send to the webservice. the only way that i have been able to do it is by using dim and redim and every article i have read so far say s that this is very inneficient.
so how do i do it?
client side app code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim xlApp As New Excel.Application Dim xlWorkbook As Excel.Workbook Dim xlWorksheet As Excel.Worksheet Dim validateThisJournal As New finfunctions.finfunctions Dim range As Excel.Range Dim rowCount As Integer Dim columnCount As Integer Dim Obj As Object 'Dim ProductList As New System.Collections.Generic.List(Of String) Dim fundlist As List(Of String) Dim orglist As List(Of String) Dim proglist As List(Of String) Dim acctlist As List(Of String) Dim debitlist As List(Of String) Dim creditlist As List(Of String) Dim rowNumber As List(Of String) 'Dim fundlist As System.Array ' fundlist = System.Array.CreateInstance(GetType(String), ) 'Dim fundlist As finfunctions.finfunctions 'Dim orglist As ArrayList() 'Dim proglist As ArrayList() 'Dim acctlist As ArrayList() 'Dim debitlist As ArrayList() 'Dim creditlist As ArrayList() 'Dim rowNumber As ArrayList() Dim strFilename As String OpenFD.InitialDirectory = "C:\" 'OpenFD.Filter = "excels|*.xls|*.xlsx" OpenFD.ShowDialog() strFilename = OpenFD.FileName FileNameDisplayBox.Text = strFilename xlApp.DisplayAlerts = False xlApp = New Excel.ApplicationClass xlWorkbook = xlApp.Workbooks.Open(strFilename) xlWorksheet = xlWorkbook.Worksheets("JV") xlApp.DisplayAlerts = False range = xlWorksheet.UsedRange Dim adrrs As String Dim adrrsSub As String 'Dim countfund As Integer 'Dim countorg As Integer 'Dim countprog As Integer 'Dim countacct As Integer 'Dim countdebit As Integer 'Dim countcredit As Integer 'Dim countrow As Integer 'count = 0 ' read the excel spreadsheet and then load the list of strings to send into the database ' for valiadation. For rowCount = 13 To 100 'do 100 rows For columnCount = 1 To 8 'do 8 columns. 'adrrs = range.Cells(rowCount, columnCount).Address Obj = CType(range.Cells(rowCount, columnCount), Excel.Range) adrrs = range.Cells(rowCount, columnCount).Address adrrsSub = adrrs.Substring(1, 1) 'count = count + 1 If adrrsSub = "A" And Obj.value IsNot Nothing Then ' ' ReDim fundlist(countfund) 'ReDim rowNumber(countfund) fundlist.Add(Obj.value) 'Journal.f_row_number = (rowCount) rowNumber.Add(rowCount) 'countfund = countfund + 1 End If If adrrsSub = "B" Then ' ReDim orglist(countorg) orglist.Add(Obj.value) 'countorg = countorg + 1 End If If adrrsSub = "C" Then 'ReDim acctlist(countacct) acctlist.Add(Obj.value) 'countacct = countacct + 1 End If If adrrsSub = "d" Then 'ReDim proglist(countprog) proglist.Add(Obj.value) 'countprog = countprog + 1 End If If adrrsSub = "G" Then ' ReDim debitlist(countdebit) debitlist.Add(Obj.value) 'countdebit = countdebit + 1 End If If adrrsSub = "H" Then 'ReDim creditlist(countcredit) creditlist.Add(Obj.value) ' countcredit = countcredit + 1 End If 'MsgBox(Obj.value) If adrrsSub = "A" And (Obj.value) Is Nothing Then 'i had to exit the for with a goto statement i just couldn't 'get the exit for to work because the values were essenstially located 'there are 2 exit fors so by using the subend i get out of the loop 'completely. GoTo subend End If Next Next 'validateThisJournal.ValidateJournal(fundlist, orglist, proglist, acctlist, debitlist, creditlist, rowNumber) 'Dim cnt As Integer = fundlist.RemoveAll(Function(x) x.Contains("")) subend: 'fundlist.ToArray() validateThisJournal.ValidateJournal(fundlist, orglist, proglist, acctlist, debitlist, creditlist, rowNumber) xlApp.DisplayAlerts = False xlWorkbook.Saved = True xlWorkbook.Close() xlApp.Quit() releaseObject(xlApp) releaseObject(xlWorkbook) releaseObject(xlWorksheet) ' MsgBox(strFilename) End Sub
code for the webserivce
Public Function ValidateJournal(ByVal w_fund As String(), _ ByVal w_org As String(), _ ByVal w_prog As String(), _ ByVal w_acct As String(), _ ByVal w_dr_ind As String(), _ ByVal w_cr_ind As String(), _ ByVal w_row As String()) As JVAL
i get this awful error when the client side
Error 1 Value of type 'System.Collections.Generic.List(Of String)' cannot be converted to '1-dimensional array of String'.
how do i do this correctly a code sample in vb.net would be most helpful
thanks
Friday, July 1, 2011 6:17 AM
Answers
-
User2089553522 posted
i figuered it out. i had to. fundlist.toArray
Thanks everyone
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, July 1, 2011 6:42 AM
All replies
-
User-843484705 posted
check here on ASP.Net Thread: http://forums.asp.net/t/230387.aspx/1?Passing+an+array+of+objects+back+from+a+webservice
In Jquery: http://stackoverflow.com/questions/1457637/how-do-you-pass-an-array-string-to-a-web-service-via-jquery
here as well: http://bytes.com/topic/visual-basic-net/answers/373516-value-type-string-cannot-converted-1-dimensional-array-string
Friday, July 1, 2011 6:32 AM -
User2089553522 posted
i figuered it out. i had to. fundlist.toArray
Thanks everyone
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, July 1, 2011 6:42 AM