syntax help: binding one dataset to two dropdown lists

  • Thread starter Thread starter Darrel
  • Start date Start date
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
 
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.
 
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

Back
Top