Structure and array and function result

kiwi

Newcomer
Joined
Jul 17, 2006
Messages
1
Hi! I have this problem I create a web service with a function that take some result from a db, this result must be insered (Return of my function) in a structure, to create this result:

Code:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=
"http://www.w3.org/2001/XMLSchema" xmlns:soap=
"http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <SERVS1Response xmlns="http://www.contoso.com/Response">
      <SERVS1Result> 
         <NumeroComm>int</NumeroComm> 
          <Comm> 
           <SComm> 
            <Nome>string</Nome>
            <Indirizzo>string</Indirizzo>
            <Cap>string</Cap>
            <Comune>string</Comune>
            <SiglaProvincia>string</SiglaProvincia>
            <Email>string</Email>
            <telefono>string</telefono>
          </SComm> 
            <SComm>
            <Nome>string</Nome>
            <Indirizzo>string</Indirizzo>
            <Cap>string</Cap>
            <Comune>string</Comune>
            <SiglaProvincia>string</SiglaProvincia>
            <Email>string</Email>
            <telefono>string</telefono>
          </SComm>
       </Comm>
        </SERVS1Result>
    </SERVS1Response>
  </soap:Body>
</soap:Envelope>

I try this code but I receive this error:

invalid cast from type 'Object()' to SComm()

the code is

Code:
Public Function SERVS1(ByVal istat As String) As SERVS1Result()

IfNot risolvi = ""Then
objConn.Open()
Dim prova AsNew SERVS1Result '<-----------//
Dim Com = prova '<----------------//
Dim pc AsString
Dim i AsInteger = 0
Dim x AsInteger = 0
Dim c AsInteger
Dim objCmd2 AsNew OleDbCommand("Connection String'", objConn)
Dim objReader2 As OleDbDataReader
objReader2 = objCmd2.ExecuteReader
While objReader2.Read
pec = (objReader2.GetString(9))
If pc = "Y"Then

ReDimPreserve Com.Comm(i) '<---------------//
Com.Comm(i).Nome = objReader2.GetString(2) 'Sede <--------------//
Com.Comm(i).Indirizzo = objReader2.GetString(4) 'indirizzo
Com.Comm(i).telefono = objReader2.GetString(5) 'telefono
Com.Comm(i).Email = objReader2.GetString(8) 'email
Com.Comm(i).Cap = CapCom
Com.Comm(i).Comune = Comune
Com.Comm(i).SiglaProvincia = Provincia
i = i + 1
EndIf
EndWhile
objConn.Close()
objConn.Dispose()
Return Com '<-----------------------------//
EndIf
EndFunction
'----------------------------------------------------------------------
PublicStructure SERVS1Result'<-------------------//
Public NumeroComm AsInteger
Public Comm() As SComm '<-----------------//
PublicStructure SComm
Public Nome AsString
Public Indirizzo AsString
Public Cap AsString
Public Comune AsString
Public SiglaProvincia AsString
Public Email AsString
Public telefono AsString
EndStructure
EndStructure

If you don't understand what i say is because i'm italian but i need good help!!!
 
Back
Top