Hello all,

i am trying to put table column to array using Visual Basic 2008 form. As i do not need to update back values to database i have used DataReader.

Private Sub Button1_click (,,,,,,,,,,) Handles Button1.Click

Dim cn As String
cn="Data Source='C:\Temp\DB\DBaze.sdf' "

Dim qry As String = "SELECT Name FROM cTable"

Dim conn As SqlServerCe.SqlCeConnection = New SqlServerCe.SqlCeConnection(cn)

Try

conn.Open()

Dim cmd As New SqlServerCe.SqlCeCommand(qry, conn)
Dim rdr As SqlServerCe.SqlCeDataReader=cmd.ExecuteReader()

While rdr.Read()
ListBox1.Items.Add(rdr("Name"))
End While

Catch ex As Exception

End Try

End Sub

As you can see i retrieve records from Name column and put them into ListBox:

While rdr.Read()
ListBox1.Items.Add(rdr("Name"))
End While

but also i need to put them into array. I have tried this, but with no luck:

Dim mArray() As String
Dim i as inteher = 0

While rdr.Read()
ListBox1.Items.Add(rdr("Name"))
mArray(i) +=rdr("Name")
i +=1
End While

Anybody could help me to solve my problem?

Thank you in advance!

This question has already been answered. Start a new discussion instead.