0
在這裏,我只想將每行的值用「# - #」作爲分隔符存儲到1個變量中,並將它們附加到字符串列表中,但它不是工作,有沒有辦法做到這一點?在此先感謝如何將數據庫查詢添加到字符串列表
Private result As List(Of String)
Public Function GetFromDB()
Dim values As String
Try
result = New List(Of String)
myConn = New SqlConnection("SERVER=ABALTAZAR-L1\SQLEXPRESS;Database=test;Integrated Security=True;")
myCmd = myConn.CreateCommand
myCmd.CommandText = "SELECT * FROM tbl_Item"
myConn.Open()
myReader = myCmd.ExecuteReader()
values = String.Join("#-#", myReader.GetValue(0), myReader.GetValue(1),
myReader.GetValue(2), myReader.GetValue(3))
result.Add(values)
myConn.Close()
Catch ex As Exception
MsgBox(ex)
End Try
Return result
End Function
爲什麼?也許你的問題更好地以另一種方式解決 – scsimon