.NETGURU
How to make multiple queries with the same connection
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngdata' list.


Marcelino Ramirez Maldonado
-- Moved from [aspngfreeforall] to [aspngdata] by Tony Stark <Click here to reveal e-mail address> --

Hello!

Can anyone of you tell me please how can make multiple queries with the same
connection object?

I open the connection, and then open a DataReader. After that, i need to
make another query but i cannot open another data reader because there is
the first one still associated with the connection, and i cannot close it
yet.

what can i do?

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com

Reply to this message...
 
    
Stefan Walther
If using SQLDataReader you have to close the DataReader before opening
another one, another possibility would be to use an additional Connection
....

But I'm too searching for better ways to get rid of this problem, especially
when building business objects I do not know at the moment what my
functions should return

SQLDataReader ??? - not the perfect way (see above)
DataView
DataAdapter
XML
???
whatever

Any ideas from other list-members would be nice ...

Grettings

Stefan

----- Original Message -----
From: "Marcelino Ramirez Maldonado" <Click here to reveal e-mail address>
To: "aspngdata" <Click here to reveal e-mail address>
Sent: Thursday, June 27, 2002 5:07 PM
Subject: [aspngdata] How to make multiple queries with the same connection

> -- Moved from [aspngfreeforall] to [aspngdata] by Tony Stark
<Click here to reveal e-mail address> --
[Original message clipped]

Reply to this message...
 
    
Liz
if you're using DataReader, you should be able to stack your SQL commands ..
"SELECT * from tableA; SELECT * from tableB;" and use the NextResult method
to access all the result sets .. I haven't done it yet so I can't confirm
...

"Marcelino Ramirez Maldonado" <Click here to reveal e-mail address> wrote in message
news:676117@aspngdata...
[Original message clipped]

Reply to this message...
 
    
Stefan Walther
Thanks Liz,

that's maybe one solution, I'll have to test it, but the problem ist,
that at the moment when selecting from the first table I do not
know the exact second SQL-statement ...

Now I have solved it by putting the results of the first SQL-statement
(fetched by SQLDataReader) inside an array, then closed the DataReader
and opened another one ...

But this way is quite tricky and annoying, so is there a better possiblity
... ???

Greetings

Stefan

----- Original Message -----
From: "Liz" <Click here to reveal e-mail address>
Newsgroups: aspngdata
To: "aspngdata" <Click here to reveal e-mail address>
Sent: Friday, June 28, 2002 7:37 AM
Subject: [aspngdata] Re: How to make multiple queries with the same
connection

> if you're using DataReader, you should be able to stack your SQL commands
..
> "SELECT * from tableA; SELECT * from tableB;" and use the NextResult
method
[Original message clipped]

Reply to this message...
 
    
Liz
when you say this, I'm wondering if you're using the result set from
statement #1 as a WHERE predicate in statement #2 ... if so, you might
accomplish all of this a lot more cleanly and painlessly by reformulating
your SQL and using a subquery, on the order of :

SELECT * FROM employees WHERE employee_id IN (SELECT employee_id FROM
great_employees WHERE salary < 10000)

then there's only one result set to deal with, no array processing, etc ...

sorry if this is off the mark or if I've inadvertantly derogated your SQL
skills ... thought I'd mention it anyway just in case it fits your scenario

L

"Stefan Walther" <Click here to reveal e-mail address> wrote in message
news:677273@aspngdata...
[Original message clipped]

Reply to this message...
 
 
System.Data.Common.DataAdapter
System.Data.DataView




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification