what am i missing - taking values from do to array

jnash

Well-known member
Joined
Oct 20, 2006
Messages
111
Programming Experience
Beginner
im trying to retrieve all the email address's from my db ad put them into a array, for ms access i always used a object reader, not as simple on mysql!!!

VB.NET:
    Public Sub retrieveAddress()

        Dim address As String

        Dim myCommand As New MySqlCommand
        Dim myReader As MySqlDataReader
        Dim strSQL As String

        strSQL = "SELECT EmailAddress FROM tblmember"

        'conn.ConnectionString = strSQL

        conn.Open()

        myCommand.Connection = conn
        myCommand.CommandText = strSQL
        myReader = myCommand.ExecuteReader

        While myReader.Read

            address = myReader.GetName(2)
            MsgBox(address)

        End While

        If conn.State <> ConnectionState.Closed Then conn.Close()
        '  SendEmailMerge()
    End Sub
 
Read the DW2 link in my signature, either section "Simple app" or section "Fetching data into your app"

Do not use an array, they are prehistoric and simplistic. The DW2 link will show you how to fill a DataTable which is a client side data container designed for holding database data. It can be accessed just like a 2D array:

myDataTable.Rows(0)(0) ... myDataTable.Rows(X)(Y)

It supercedes array in every way for use with database data
 
Back
Top