syntax help: binding one dataset to two dropdown lists

D

Darrel

I'm trying to perform a SQL query and then bind the results to two different
dropdownlists. Unfortunately, I can only get it to bind to one...whichever
one of the two I try to bind first:

Dim objConnect As New OleDb.OleDbConnection(strConnect)
objConnect.Open()
Dim objCommand As New System.Data.OleDb.OleDbCommand(strSQL, objConnect)
DropDownList_category1.DataSource = objCommand.ExecuteReader()
DropDownList_category1.DataTextField = "directoryCategoryName"
DropDownList_category1.DataValueField = "directoryCategoryID"
DropDownList_category1.DataBind()
Dim objCommand2 As New System.Data.OleDb.OleDbCommand(strSQL, objConnect)
DropDownList_category2.DataSource = objCommand2.ExecuteReader()
DropDownList_category2.DataTextField = "directoryCategoryName"
DropDownList_category2.DataValueField = "directoryCategoryID"
DropDownList_category2.DataBind()
objCommand.Dispose
objCommand2.Dispose
objConnect.Close()

I'm probably missing a simple syntax concept, but I'm stumped.

-Darrel
 
K

Kumar Reddi

I think the problem in your case is, the first dataReader is not closed
after it returns. A dataReader needs to be closed before the connection
associated with it can be reused.
 
D

Darrel

I think the problem in your case is, the first dataReader is not closed
after it returns. A dataReader needs to be closed before the connection
associated with it can be reused.

Thanks, Kumar...I'll give that a shot.

-Darrel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top