using a datareader to fill an ArrayList help?

natethenotsogreat

New member
Joined
Apr 14, 2007
Messages
2
Programming Experience
Beginner
VB.NET:
Dim cmd As OleDb.OleDbCommand
Dim dr As OleDb.OleDbDataReader
Dim i As Integer = 0
 
Dim TestArray As ArrayList = New ArrayList
 
 
ConDatabase.Open()
 
cmd = New OleDb.OleDbCommand("SELECT fldValues FROM tblTest", ConDatabase)
dr = cmd.ExecuteReader
 
 
While dr.Read()
 
TestArray.Add(dr.ToString)
 
End While
 
dr.Close()
ConDatabase.Close()
 
i = 0
 
For i = i To ("fldValues".Length - 1)
 
Me.lstTest.Items.Add(TestArray(i))
 
Next i
This is the result that is listed in the listbox:
System.Data.Oledb.OledbDataReader

this result is loaded into the arraylist and then into the listbox for as many items as I have in the database field fldValues.

I want the actual value to enter into the arraylist and into the listbox.

Any help?

thanks
 
Last edited by a moderator:
Your:
While dr.Read()
TestArray.Add(dr.ToString)
End While

?? maybe shoud be ??
testarray.add(dr("fldValues").tostring
 
Er. Dont bother. Create a DataAdapter, and have it use the SQL to fill a DataTable with the results, then simply set the .DataSource of the control to be the DataTable

Read the DW1 link in my signature
 
Back
Top