Imports System.Data.OleDb


Module Module1


    Sub Main()
        Dim Cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\mibase.mdb;Persist Security Info=False")
        Cn.Open()
        Dim comando As OleDbCommand
        comando = New OleDbCommand()
        comando.CommandText = String.Format("SELECT Telefono FROM empleados ")

        comando.Connection = Cn
        Dim lector As OleDbDataReader
        lector = comando.ExecuteReader


        Do While lector.Read

            Console.WriteLine(lector("Telefono"))

        Loop

       
        Dim nombres As New ArrayList




            While lector.Read
            nombres.Add(lector("Telefono"))

            Console.WriteLine(nombres.ToString)

            End While

        For Each datos As String In nombres
            Console.WriteLine(datos)


        Next


    End Sub

End Module

I have this..but is not working I cant save data in the array and the array is not printing is like empty

SOLVED =) ...like 1 hour but my mistake was in for each...

Imports System.Data.OleDb


Module Module1


    Sub Main()
        Dim Cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\mibase.mdb;Persist Security Info=False")
        Cn.Open()
        Dim comando As OleDbCommand
        comando = New OleDbCommand()
        comando.CommandText = String.Format("SELECT Nombre FROM empleados ")

        comando.Connection = Cn
        Dim lector As OleDbDataReader


        lector = comando.ExecuteReader
        Dim x As Integer = 0


        Dim milista As New ArrayList

        While lector.Read
            milista.Add(lector.GetString(0))
            x = x + 1
        

        End While
        For Each dato As String In milista
            Console.WriteLine(dato)


        Next


    End Sub

End Module
This article has been dead for over six months. Start a new discussion instead.