'Store sql query value into a list of string myListOfStrings
Dim myListOfStrings As New List(Of String)
Dim conStr = "write your connection string here"
Using connection As New SqlConnection(conStr )
Dim sql As String = "write your sql query here"
Dim command As New SqlCommand(sql, connection)
Using reader As SqlDataReader = command.ExecuteReader()
While reader.Read()
myListOfStrings.Add(reader("column_name"))
End While
End Using
End Using
'Convert List of String to a String separated by a comma(,) delimiter
String.Join(",", myListOfStrings.ToArray())In this Code snippet we will see how to Store sql query value into a List of String and Convert List of String to a String separated by a comma(,) Delimiter
