我正在浏览遗留代码而不熟悉VB或Webservices tbh。我需要将其显示为数组,但在运行操作时,它不会返回实际的列表项。我得到以下内容:
anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" xmlns:d1p1="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/" d1p1:type="q1:string">[]</anyType
我错过了什么?
Public Shared Function GetVehicleFromVINforDecode(ByVal vin As String)
Dim VINlist As New List(Of VINResult)
Dim strPattern As String
strPattern = GetVinPattern(vin)
Using conn As New SqlConnection(ConnectionStrings.CKConnectionString)
Dim sqlComm As New SqlCommand("select * from VehicleData.dbo.vin_pattern where vin_pattern = '" & strPattern & "'", conn)
conn.Open()
Using r As SqlDataReader = sqlComm.ExecuteReader
While r.Read()
Dim VINitem = New VINResult()
VINitem.Make = (r("Make"))
VINitem.Model = (r("Model"))
VINitem.Year = (r("Year"))
VINitem.Cylinders = (r("DEF_ENGINE_CYLINDERS"))
VINitem.Drive = (r("DRIVE_TYPE"))
VINitem.Liters = (r("DEF_ENGINE_SIZE"))
VINitem.Style = (r("Style"))
VINitem.TransmissionSpeed = (r("DEF_TRANS_SPEEDS"))
VINitem.TransmissionType = (r("DEF_TRANS_TYPE"))
VINitem.Trim = (r("Trim"))
VINitem.FuelType = (r("FUEL_TYPE"))
VINlist.AddRange(VINitem)
End While
End Using
End Using
Return VINlist
End Function
答案 0 :(得分:0)
List(Of T)
和数组不是一回事,根据我在Stack Overflow上的经验,Web服务通常对前者没有很好的支持。
在返回时尝试调用列表中的ToArray()
,以便将其转换为常规数组:
yielded