If i have a table with say x columns and y rows
how do i get the contents of the 'i'th column into a arraylist

Well the number of rows really do not matter.

In the code that I have posted below, I hold the number of rows in a variable named total.

I have chosen to extract the contents of the first column, if you want to do so for the column number x, substitute 0 by x-1 in the statement below in the code-

a(i) = ds.Tables("trial1").Rows(i).Item(0)

I am adding the contents retrieved to a ListBox, just as a check.

Public Class Form1

    Dim a() As String
    Dim total As Integer

    Dim cn As New Odbc.OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=shreyas; User=root;Password=;")
    Dim cmd As Odbc.OdbcCommand
    Dim adp As Odbc.OdbcDataAdapter
    Dim ds As New DataSet


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cn.Open()
        cmd = New Odbc.OdbcCommand("Select * from trial1", cn)
        adp = New Odbc.OdbcDataAdapter(cmd)
        adp.Fill(ds, "trial1")
        'Count the number of rows
       total = ds.Tables("trial1").Rows.Count - 1

        Dim i As Integer

        ReDim a(0 To total)
        For i = 0 To total
            a(i) = ds.Tables("trial1").Rows(i).Item(0)
        Next


        Dim j As Integer

        For j = 0 To total
            Me.ListBox1.Items.Add(a(j))
        Next




    End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.