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

Using two Datareader

Hi all,
I have to use two separate queries in an .aspx file.
What is the way to use two Datareaders for that.

Or is there any other solution?

Any kind of help or coding or documentation is
appreciated.

Thanks,
Randall
Nov 17 '05 #1
3 1072
You could use a query that returns 2 resultsets.
When you're done with the first one, call NextResult.
Here's more info:
http://msdn.microsoft.com/library/de...esulttopic.asp

Or you could use one or two DataSets instead of DataReaders.
Here's more info:
http://msdn.microsoft.com/library/de...classtopic.asp

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


"Randall" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
Hi all,
I have to use two separate queries in an .aspx file.
What is the way to use two Datareaders for that.

Or is there any other solution?

Any kind of help or coding or documentation is
appreciated.

Thanks,
Randall

Nov 17 '05 #2
You can use

dim comm as sqlcommand = new sqlcommand("select * from
query1","select * from query2")

dim dataset1 as dataset= new dataset(comm,connectionstring)

dim da as new dataadapter

da.fill(comm)

da.table(0) for first query table
da.table(1) for second query table

Thanks
Ninan J

-----Original Message-----
Hi all,
I have to use two separate queries in an .aspx file.
What is the way to use two Datareaders for that.

Or is there any other solution?

Any kind of help or coding or documentation is
appreciated.

Thanks,
Randall
.

Nov 17 '05 #3
Thanks Ninan.
What if I have to use same table in both the queries?
Any suggestion?

Regards,
Randall.
-----Original Message-----
You can use

dim comm as sqlcommand = new sqlcommand("select * from
query1","select * from query2")

dim dataset1 as dataset= new dataset (comm,connectionstring)
dim da as new dataadapter

da.fill(comm)

da.table(0) for first query table
da.table(1) for second query table

Thanks
Ninan J

-----Original Message-----
Hi all,
I have to use two separate queries in an .aspx file.
What is the way to use two Datareaders for that.

Or is there any other solution?

Any kind of help or coding or documentation is
appreciated.

Thanks,
Randall
.

.

Nov 17 '05 #4

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

Similar topics

0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
0
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how...
2
by: Nathan Sokalski | last post by:
I have two OleDbDataReaders that I need to use at the same time. One of the DataReadersis used inside a While loop. My code is as follows: While eventreader.Read() ...
1
by: Brent | last post by:
I'm having a hard time wrapping my head around how to build a multi-dimensional array of n length out of a DataReader loop. Take this pseudo-code: ======================================= public...
3
by: Miguel | last post by:
Hi, I'm new to .NET and am using VB .NET as I am from a VB background. I am having difficulty understanding the way .NET handles, passes and uses objects. I have had a look at the Micrsoft Data...
2
by: Harry Strybos | last post by:
Hi All I have a form with about 20 check boxes and I want to persist their state to a single integer. That is to say, I want to set their Checked property to a particular bit value contained in...
2
by: jarod1701 | last post by:
Hi everyone, is there a way to access every record from a SqlDataReader via "foreach" ? I want to write a class which (besides doing some other stuff) retrieves a recordset using...
7
by: Diffident | last post by:
Hello All, I would like to use DataReader based accessing in my Data Access Layer (DAL). What is considered to be a best practice while returning from a DAL method that executes a query and...
2
by: sacha4 | last post by:
I need to make an edit page using data reader. this is my code.. Sub Page_Load() If Not IsPostBack Then Dim conn As SqlConnection Dim cmdSQL As SqlCommand ...
2
by: | last post by:
I am using a datareader to cycle through a list of records one at a time. I frequently get connection timeouts and am wondering what I am doing wrong. In more detail, I retrieve an excel...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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.