473,387 Members | 1,628 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,387 software developers and data experts.

What's the recommended way of using to SqlDataReaders in a loop?

When the original has to be open to use its values as a parameter for the
second reader? Is it still possible to use one Connection?
Nov 17 '05 #1
3 958
No. DataReaders cannot share a Connection.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Rico Alexander" <ra******@ucla.edu> wrote in message
news:uy**************@TK2MSFTNGP09.phx.gbl...
When the original has to be open to use its values as a parameter for the
second reader? Is it still possible to use one Connection?

Nov 17 '05 #2
Thanks, Kevin. I'll try replacing one with a dataset.
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:Oh**************@TK2MSFTNGP09.phx.gbl...
No. DataReaders cannot share a Connection.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Rico Alexander" <ra******@ucla.edu> wrote in message
news:uy**************@TK2MSFTNGP09.phx.gbl...
When the original has to be open to use its values as a parameter for the second reader? Is it still possible to use one Connection?


Nov 17 '05 #3
Why don't you just use the first reader and load the variable(s) you need
into an arraylist or similar structure. THen, close the reader. Open up
the second one and you already have your value.
"Rico Alexander" <ra******@ucla.edu> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl...
Thanks, Kevin. I'll try replacing one with a dataset.
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:Oh**************@TK2MSFTNGP09.phx.gbl...
No. DataReaders cannot share a Connection.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Rico Alexander" <ra******@ucla.edu> wrote in message
news:uy**************@TK2MSFTNGP09.phx.gbl...
When the original has to be open to use its values as a parameter for the second reader? Is it still possible to use one Connection?



Nov 17 '05 #4

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

Similar topics

28
by: Vishal Naidu | last post by:
i m new to the C world... i ve been told by my instructors not to use goto stmt.. but no one could give me a satisfactory answer as to why it is so.. plz help me out of this dilemma, coz i use...
2
by: Bob | last post by:
Some guidance is requested. I will be developing an application in C#.NET. This app will require a db, the organization size is approx 50 users, all of which all part time users, maybe 10%...
1
by: benmorganpowell | last post by:
I have a small windows service which connects to a POP3 server at defined intervals, scans the available messages, extracts the required information and inserts the data into a SQL database. I am...
13
by: Kyle Adams | last post by:
I don't know where is the right place to ask this so I will start here. Can someone explain to me what these represent? I think they all have to do with the middleware level, but I really don't...
1
by: mark r. | last post by:
Hi, all: I know it's strongly recommended against, but I believe my application runs much more smoothly if I call GC.Collect() in a worker loop. If I omit the call, I get an OutOfMemoryException...
16
by: Luqman | last post by:
Is it recommended to use datasets in ASP.Net 2.0 / VS.Net 2005 ? Best Regards, Luqman
1
by: Andy | last post by:
Hi, I was wondering if someone could advise on if the following is possible. I have one website that is available to the public using Forms authentication and the Membership class, it...
1
by: Chris | last post by:
hi, I need to use a few SQLDataReader objects in my application. I need to do something like that: System.Data.SqlClient.SqlConnection conn = new SqlConnection(string); conn.Open();...
22
by: davy.zou | last post by:
I found the code for a program that is suppose to be able to work out the sumation of i from 1 to a certain integer n. however, when I implemented to code into Visual C++, it doesn't work. The...
22
by: gillisct | last post by:
I'd like to say I have a basic control of the C language. Is there any reccomended reading upon completion of K&R? Are there any projects someone new to C could study/watch over/ and eventually...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.