0
我在DB的一些數據,這些數據我使用一個WebService得到一個List(串),並使用下面的代碼返回的列表現在列表(串)找出數據庫字段的值
Public Function getDetails() As List(Of String)
Dim Connection As SqlConnection = Nothing
Dim Command As SqlCommand = Nothing
Dim DataReader As SqlDataReader = Nothing
Try
Dim MyList As New List(Of String)
Connection = New SqlConnection("Connection String")
Connection.Open()
Command = New SqlCommand("select * from TBL", Connection)
DataReader = Command.ExecuteReader()
While (DataReader.Read)
MyList.Add(DataReader("Col1"))
MyList.Add(DataReader("Col2"))
MyList.Add(DataReader("Col3"))
MyList.Add(DataReader("Col4"))
End While
If MyList.Count <> 0 Then
Return MyList
Else
Return Nothing
End If
Catch ex As Exception
Return Nothing
Finally
DataReader.Close()
Connection.Close()
End Try
End Function
我在其中利用即時通訊網絡服務和獲取以下
Dim webQuery As QueryWebService.Service = New QueryWebService.Service
Dim queryDetails As String()
Dim i As Integer = 0
queryDetails = webQuery.getStudentQuery()
While i < queryDetails.Length
txtQuery.Text = txtQuery.Text + " " + queryDetails.GetValue(i)
i = i + 1
End While
值在使用碼的值是罰款VB.net程序,但他們是在一個String(),我要顯示的每個列的值在不同的TextField(多行)中,我該怎麼做?
謝謝。
感謝您的回覆,但如果我將其更改爲列表,我收到錯誤消息。例如,如果我把它改爲這個'Dim queryDetails As List(Of String)'我得到這個錯誤「類型'1維數組的字符串'的值不能轉換爲'System.Collections.Generic.List(Of String) 「 – raziiq 2012-02-10 06:17:45