473,396 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

syntax help: binding one dataset to two dropdown lists

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
Nov 19 '05 #1
2 1396
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.
--
Kumar Reddi
http://kumarreddi.blogspot.com
"Darrel" <no*****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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

Nov 19 '05 #2
>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
Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a...
3
by: Binod Nair | last post by:
Hi All, This is what I am trying to do.I have an aspx page with the the following code block. <asp:DropDownList id="DropDownList1" runat="server" DataSource="<%# GetUsers%>"...
3
by: Just D | last post by:
Hi, If anybody needs to show some data retrieved from the database table, what method is more preferrable? 1. DataSet ds = ...; DataGrid.Data.Source.ds; DataGrid.Bind(); 2. Write a custom...
1
by: Andrea Williams | last post by:
I'm trying to bind to a Template Item that I created and fill the dropdown with a value from the datagrid DataSet. However, if the value is "", then I want to Insert a "" option to the list. I'm...
2
by: Fraggle_Rock_1 | last post by:
I have a dataset like so |ID | type | Name ------------------ |1 | 1 | ham |2 | 2 | fish |1 | 2 | lard |2 | 1 | spam
4
by: Darrel | last post by:
This is a followup to a previous question. I'm trying to grab some data and bind it to two different dropdown lists. (same data in each one). I can't seem to populate them both without resorting...
1
by: Vaughn Haybittle | last post by:
Hi, I am writing an ASP.Net application that uses a handful of dropdown lists. These lists appear on many of the .apx pages in the application. I would like to persist the data that is used to...
9
by: Timm | last post by:
I have an ASP.NET 2.0 page with two DropDownLists. I am using declarative data binding wherever possible and trying to minimize the use of code. The list of values in DropDownList DDL2 should be...
3
by: GaryDean | last post by:
I want to start out my question on a new thread..... Create a new web app in vs 2005. Add a dataset that has a 'Select Lastname from Employees' on the northwind database to the App_Code folder...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.