myReader (1 Viewer)

accessman2

Registered User.
Local time
Yesterday, 20:55
Joined
Sep 15, 2005
Messages
335
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myReader As System.Data.OleDb.OleDbDataReader

OleDbConnection1.Open()
myReader = OleDbCommand1.ExecuteReader()
DataGrid1.DataSource = myReader
DataGrid1.DataBind()

DropDownList3.DataSource() = myReader
DropDownList3.DataTextField = "Name"
DropDownList3.DataValueField = "Name"
DropDownList3.DataBind()

...
End Sub

I used this codes in the Page_Load function, The datagrid1 works, but the dropdownlist doesn't work. What's wrong with it?
 

dan-cat

Registered User.
Local time
Today, 04:55
Joined
Jun 2, 2002
Messages
3,433
The datareader is an optimized forward-only record reader. It is designed to read through your selected records once and once only. If you wish to re-use the data I would recommend you use a dataset or parse the records into an array of some kind.
 

Users who are viewing this thread

Top Bottom