How would I go about storing one column in a database in a Array?
And then how would I extract those results from the array?
Printable View
How would I go about storing one column in a database in a Array?
And then how would I extract those results from the array?
Or I should say, How would I go about taking one column from a database result and store it into an array.
;)
this?
VB Code:
Dim cn As New SqlConnection() Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load cn.ConnectionString = "user id=sa;password=password;initial catalog=northwind" cn.Open() Dim cm As New SqlCommand("select * from territories", cn) Dim dr As SqlDataReader = cm.ExecuteReader Dim a As New ArrayList() While dr.Read a.Add(dr(1)) ' second column End While Dim s As String Dim s2 As String For Each s In a s2 &= s & Constants.vbCrLf Next MessageBox.Show(s2) End Sub