473,699 Members | 2,518 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

reuse SQLDataReader in multiple dropdownlists?

I would like to reuse a SQLDataReader that is populated with information as
the datasource for multiple dropdownlists. Unfortunately, the first DDL
closes the SDR and my code fails on the second DDR. Is there a way to
copy/clone the SDR? Is there another solution?

Thanks,

Craig Buchanan
Nov 18 '05 #1
4 3621
DataSet. Can bind to as many controls as you wish.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** *************** *************** *************** **********
Think Outside the Box!
*************** *************** *************** *************** **********
"Craig Buchanan" <so*****@somewh ere.com> wrote in message
news:eK******** ******@TK2MSFTN GP09.phx.gbl...
I would like to reuse a SQLDataReader that is populated with information as the datasource for multiple dropdownlists. Unfortunately, the first DDL
closes the SDR and my code fails on the second DDR. Is there a way to
copy/clone the SDR? Is there another solution?

Thanks,

Craig Buchanan

Nov 18 '05 #2
Not to mention it's disconnected. DataReaders keep an open connection to the
database so re-using the same DataReader will waste a lot of bandwidth and
server time fetching the rows again and again. The DataSet (or DataTables
for that matter) fetch all the results and then close the connection. Much
more efficient if you are using the data repeatedly and much nicer on the
database.

Hope this helps
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Cowboy (Gregory A. Beamer)" <No************ @comcast.netNoS pamM> wrote in
message news:O7******** ******@TK2MSFTN GP11.phx.gbl...
DataSet. Can bind to as many controls as you wish.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** *************** *************** *************** **********
Think Outside the Box!
*************** *************** *************** *************** **********
"Craig Buchanan" <so*****@somewh ere.com> wrote in message
news:eK******** ******@TK2MSFTN GP09.phx.gbl...
I would like to reuse a SQLDataReader that is populated with information

as
the datasource for multiple dropdownlists. Unfortunately, the first DDL
closes the SDR and my code fails on the second DDR. Is there a way to
copy/clone the SDR? Is there another solution?

Thanks,

Craig Buchanan


Nov 18 '05 #3
Another solution is that you can bind your second DDL to your first.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"Craig Buchanan" <so*****@somewh ere.com> wrote in message
news:eK******** ******@TK2MSFTN GP09.phx.gbl...
I would like to reuse a SQLDataReader that is populated with information as the datasource for multiple dropdownlists. Unfortunately, the first DDL
closes the SDR and my code fails on the second DDR. Is there a way to
copy/clone the SDR? Is there another solution?

Thanks,

Craig Buchanan

Nov 18 '05 #4
how is this done? the datasource is write only.

thanks,

craig

"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> wrote in message
news:uA******** ******@TK2MSFTN GP10.phx.gbl...
Another solution is that you can bind your second DDL to your first.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"Craig Buchanan" <so*****@somewh ere.com> wrote in message
news:eK******** ******@TK2MSFTN GP09.phx.gbl...
I would like to reuse a SQLDataReader that is populated with information

as
the datasource for multiple dropdownlists. Unfortunately, the first DDL
closes the SDR and my code fails on the second DDR. Is there a way to
copy/clone the SDR? Is there another solution?

Thanks,

Craig Buchanan


Nov 18 '05 #5

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

Similar topics

4
9460
by: lakshmi | last post by:
Hi all, My requirement is I need to have three different recordsets open at the same time. Traversing through the 3 recordsets, I would check on the data and based on some rules, return an object from my function. Will it be efficient to use a SQLDataReader or a DataSet for this situation? I understand from the documentation that there can be only one SQLDataReader associated with a connection open at a time. So, it seems like I can't...
1
3261
by: Arvind P Rangan | last post by:
Hi All, How do you get all the values of a sqldatareader if it contains multiple resultset. Using sqldatareader.nextresult and sqldatareader.read e.g. While sqldatareader.read ' If not sqldatareader then sqldatareader.nextresult
2
1324
by: Harry | last post by:
Hi, Quick question regarding dropdownlists. On one page I have 10 asp:dropdownlists. The user selects an option from a dropdown list and then it updates an asp:label with the relevant text. The user must select an option from each dropdown list. All the dropdownlists are to be populated from a SQL database.
11
3145
by: Ranginald | last post by:
This question is about how to handle an .aspx page that references multiple methods and where to store these methods (e.g. one codefile or multiple codefiles). PREFACE ======== I have a simple category/product asp.net/C# web site I am coding in web dev express and laying out in dreamweaver MX. I find the layout tools in web express difficult to use and implementation of complex templates much easier in dwmx.
19
2373
by: jacob navia | last post by:
There is an interesting discussion running in Slashdot now, about code reuse. The thema of the discussion is here: < quote > Susan Elliot Sim asks: "In the science fiction novel, 'A Deepness in the Sky,' Vernor Vinge described a future where software is created by 'programmer archaeologists' who search archives for existing pieces of code, contextualize them, and combine them into new applications. So
3
1647
by: RSH | last post by:
Hi, I am having this very bizarre occurance with 4 dropdown lists on my ASP .Net page. Each control has its own unique id. When the user selects a value from each of the dropdownlists it is written correctly to the database. HOWEVER...When setting the SelectedIndex property of each of the controls in the codebehind (.net 1.1) I get an exception "A dropdownlist can not have
1
1306
by: klaul | last post by:
I've been trying to do this for a day and a half now, and am clearly getting nowhere! The database I'm using is used to keep a log of service calls to various companies. When the user inserts data, they choose the company from a static list, but the reference number is user-supplied. The data is brought back using a GridView. I am trying to create two linked dropdownlists so that I can search the gridview (so that the items on the second...
4
3662
by: Cirene | last post by:
I have a sqldatareader that I use to read some data. Later I do a dr.close. In the same sub I later to "dr = MyCommand.ExecuteReader" because I'm trying to reuse the var with a totally different stored proc. When the code runs I get this error on the 2nd dr.Read: System.InvalidOperationException: Invalid attempt to call Read when reader is closed. at System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout) at...
20
3435
luckysanj
by: luckysanj | last post by:
Hello Sir, I have an one problme when inserting data. I want to insert data through function cuz of reuse function. function add_rec($tbl,$flds,$val) { $sql="insert into $tbl ($flds) values($val)"; $sql_result=mysql_query($sql) or die(mysql_error());
0
8685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8613
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9172
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8908
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7745
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4374
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.