473,769 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple Select Statements in resultset

Hi,

I'm trying to use several select statements so that I don't need to call
the function several times. The next Result set always seems to read the
first select statement. I have the following:
Dim queryString As String = "SELECT TOP 1 ([tblPage].[Part]), [tblPage].
[PageNumber] FROM [tblPage] WHERE ([tblPage].[LessonID] = @LessonID) AND
[tblPage].[Part]='Motivate'; SELECT TOP 1 ([tblPage].[Part]), [tblPage].
[PageNumber] FROM [tblPage] WHERE ([tblPage].[LessonID] = @LessonID) AND
[tblPage].[Part]='Present'"

If (dataReader.Rea d = True) Then
Dim Part = dataReader("Par t")
Response.Write( "Part is "&Part)
dataReader.Next Result()
Response.Write( "Part is "&Part)
End If

So, I always get the first statement where part=motivate. I don't want to
use a Do While because I'll be doing something different with each result
set. I've just simplified it in the above example.

Thanks so much.

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #1
3 2169
Joe it is hard to see what your trying to do but if your trying to base one
query off another you might try setting up a DataRelation Collection with
multiple DataTable commands in a DataSet instead of building multiple
DataReaders or trying to join multiple tables within a Select Command. It
might be easier for you to handle your Data that way

"Joe via DotNetMonster.c om" wrote:
Hi,

I'm trying to use several select statements so that I don't need to call
the function several times. The next Result set always seems to read the
first select statement. I have the following:
Dim queryString As String = "SELECT TOP 1 ([tblPage].[Part]), [tblPage].
[PageNumber] FROM [tblPage] WHERE ([tblPage].[LessonID] = @LessonID) AND
[tblPage].[Part]='Motivate'; SELECT TOP 1 ([tblPage].[Part]), [tblPage].
[PageNumber] FROM [tblPage] WHERE ([tblPage].[LessonID] = @LessonID) AND
[tblPage].[Part]='Present'"

If (dataReader.Rea d = True) Then
Dim Part = dataReader("Par t")
Response.Write( "Part is "&Part)
dataReader.Next Result()
Response.Write( "Part is "&Part)
End If

So, I always get the first statement where part=motivate. I don't want to
use a Do While because I'll be doing something different with each result
set. I've just simplified it in the above example.

Thanks so much.

--
Message posted via http://www.dotnetmonster.com

Nov 19 '05 #2
Joe,

Your sample below always would return the part in the first resultset.
After each datareader.Next Result() you would need to do
Part = dataReader("Par t")
You probably also need the If (dataReader.Rea d = True) Then before the
Part = ...

Another alternative might be to UNION your SELCT statement so you just
have one resultset.

I hope that helps.

Mike Douglas

On Sat, 26 Mar 2005 18:03:24 GMT, "Joe via DotNetMonster.c om"
<fo***@DotNetMo nster.com> wrote:
Hi,

I'm trying to use several select statements so that I don't need to call
the function several times. The next Result set always seems to read the
first select statement. I have the following:
Dim queryString As String = "SELECT TOP 1 ([tblPage].[Part]), [tblPage].
[PageNumber] FROM [tblPage] WHERE ([tblPage].[LessonID] = @LessonID) AND
[tblPage].[Part]='Motivate'; SELECT TOP 1 ([tblPage].[Part]), [tblPage].
[PageNumber] FROM [tblPage] WHERE ([tblPage].[LessonID] = @LessonID) AND
[tblPage].[Part]='Present'"

If (dataReader.Rea d = True) Then
Dim Part = dataReader("Par t")
Response.Write( "Part is "&Part)
dataReader.Next Result()
Response.Write( "Part is "&Part)
End If

So, I always get the first statement where part=motivate. I don't want to
use a Do While because I'll be doing something different with each result
set. I've just simplified it in the above example.

Thanks so much.


Nov 19 '05 #3
Thanks for you help. I ended up using a DataView Object in the Dataset and
that seems to work.

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #4

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

Similar topics

8
5521
by: Sans Spam | last post by:
Greetings! I have a table that contains all of the function permissions within a given application. These functions are different sections of a site and each has its own permissions (READ, WRITE, UPDATE, DELETE) which are controlled by a web frontend and the table records are manipulated to control the permissions. Example: The Press Release section record would look like this: Username: John Doe Function Name: Press Release
0
1473
by: Ralph Freshour | last post by:
I'm not sure the follow multiple table query is the right way to do what I need to do although it seems to be working: $php_SQL = "SELECT * ". "FROM basics, personal, photos ". "WHERE basics.member_name = personal.member_name ". "AND basics.member_name = photos.member_name ". "AND basics.account_creation_date >= DATE_SUB(NOW(), INTERVAL 30 DAY)";
4
10689
by: randy.p.ho | last post by:
Using JDBC, is there a way to call a stored procedure with multiple return values? Thanks.
1
1580
by: Peter Neumaier | last post by:
Hi! I got 2 stored procedure, proc1 executes proc2, proc2 does some updates and inserts on different tables ... proc1: ALTER PROCEDURE AS
7
3391
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always either AND or OR but never mixed together. We can use Northwind database for my question, it is very similar to the structure of the problem on the database I am working on. IF(SELECT OBJECT_ID('REPORT')) IS NOT NULL DROP TABLE REPORT_SELECTION
2
2937
by: Diego | last post by:
Hi everybody! I'm using DB2 PE v8.2.3 for linux. I've defined a database with the following schema: ANNOTATION(ID,AUTHOR,TEXT) ANNOTATION_BOOK(ANNOTATION_ID,OBJECT_ID) BOOK(ID,AUTHOR,TITLE). Between the book and annotation entities there is a many-to-many
2
5096
by: =?Utf-8?B?VGVycnk=?= | last post by:
I have coded multiple select statements in a single stored procedure, and when I execute this procedure on SQL Server Management Express, I correctly get multiple result sets. But, if I try to add a new Data Source to to my VB 2005 project, and point to this stored procedure, the data source wizard only sees the 'first' select statement. Is there a way to load multiple tables in a DataSet from a single stored procedure with multiple...
2
5574
by: jaffar.kazi | last post by:
Hi All. This might be the wrong group to post this query, since it is ADO.NET related, but I couldn't find any ADO.NET group. My problem is that I want to write some queries, which use temp table because of their complexity. My final results are in the temp tables. How can I return a single result set from these multiple queries? Regards,
0
1935
by: Camfa | last post by:
Hi all, I’ve been messing around with the following question for 2 days now, and i still haven’t find a fix. So i hope you can help me. I’ll quickly show you guys the situation: There are 2 tables in my database (MainRecords and RecordLines) http://img502.imageshack.us/img502/6106/startscreencv5.png
0
9423
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
10210
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...
0
10039
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9990
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
9860
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8869
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...
0
6668
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3560
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
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.