This might be a stupid question.... I have a stored procedures, which uses
two selects. When I run the SP I get two resultsets, one very big and the
other much smaller, which is the one I want in the dataset. How do a ensure
only the last one goes in the dataset. 4 9139
"Chris" <no****@nospam. comwrote in message
news:Og******** ******@TK2MSFTN GP06.phx.gbl...
This might be a stupid question.... I have a stored procedure, which uses
two selects. When I run the SP I get two resultsets, one very big and the
other much smaller, which is the one I want in the dataset. How do a
ensure only the last one goes in the dataset.
Well, firstly do you need the SP to return both resultsets? If not, get rid
of the one you don't need... :-)
If you do, ignore the one you don't need in the DataSet.
E.g., if you are trying to bind the smaller of the two resultsets into a
GridView, you could do something like this:
DataSet MyDS = <run your SP>;
MyGridView.Data Source = MyDS.Tables[1];
MyGridView.Data Bind();
-- http://www.markrae.net
To Add to what Mark has suggested, use an extra parameter to the Stored
procedure whether to do the first select statement using a T-Sql if
condition. If we do so we can avoid populating the dataset with unwanted
data. Binding to the Gridview would now be as follows as we would expect only
one resultset from the stored proc:
DataSet MyDS = <run your SP>;
MyGridView.Data Source = MyDS.Tables[0];
MyGridView.Data Bind();
HTH
Siva
"Mark Rae" wrote:
"Chris" <no****@nospam. comwrote in message
news:Og******** ******@TK2MSFTN GP06.phx.gbl...
This might be a stupid question.... I have a stored procedure, which uses
two selects. When I run the SP I get two resultsets, one very big and the
other much smaller, which is the one I want in the dataset. How do a
ensure only the last one goes in the dataset.
Well, firstly do you need the SP to return both resultsets? If not, get rid
of the one you don't need... :-)
If you do, ignore the one you don't need in the DataSet.
E.g., if you are trying to bind the smaller of the two resultsets into a
GridView, you could do something like this:
DataSet MyDS = <run your SP>;
MyGridView.Data Source = MyDS.Tables[1];
MyGridView.Data Bind();
-- http://www.markrae.net
My suggestion (which is a alternate of the flag being sent is ) is:
Create 2 procedures.
uspEmployeeGetA ll
Select EmpID, LastName, FirstName from dbo.Employee
uspDepartmentGe tAll
Select DeptID, DepartmentName from dbo.Department
Then a wrapper usp
uspEmployeesAnd DepartmentsGetA ll
EXEC dbo.uspEmployee GetAll
EXEC dbo.uspDepartme ntGetAll
That'll work.
If you use an IDataReader, you have more control over loading data. But you
pay for it with more code.
See my blog for an example:
http://sholliday.space s.live.com/Blog/cns!A68482B9628 A842A!140.entry
"Chris" <no****@nospam. comwrote in message
news:Og******** ******@TK2MSFTN GP06.phx.gbl...
This might be a stupid question.... I have a stored procedures, which uses
two selects. When I run the SP I get two resultsets, one very big and the
other much smaller, which is the one I want in the dataset. How do a
ensure
only the last one goes in the dataset.
Mark Rae wrote:
"Chris" <no****@nospam. comwrote in message
news:Og******** ******@TK2MSFTN GP06.phx.gbl...
>This might be a stupid question.... I have a stored procedure, which uses two selects. When I run the SP I get two resultsets, one very big and the other much smaller, which is the one I want in the dataset. How do a ensure only the last one goes in the dataset.
Well, firstly do you need the SP to return both resultsets? If not, get
rid of the one you don't need... :-)
If you do, ignore the one you don't need in the DataSet.
E.g., if you are trying to bind the smaller of the two resultsets into a
GridView, you could do something like this:
DataSet MyDS = <run your SP>;
MyGridView.Data Source = MyDS.Tables[1];
MyGridView.Data Bind();
An additional benefit of doing this is that it will even run faster! :)
-- http://bytes.thinkersroom.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: jamiemcc |
last post by:
Hi,
I would like to have 1 stored procedure call another stored procedure
(which contains multiple select statements) and then be able to access
the 3 result sets.
Example
Create Procedure .
exec Multiple
--manipulate result set A
|
by: marc |
last post by:
I've been developing a stored procedure that uses a user defined
function in the query portion of the procedure. However, since the end
product needs to allow for dynamic table names, the UDF will not work.
I've been trying to get this to work with converting the UDF to a
procedure, but I'm having no luck.
Here is the background on what I'm trying to accomplish. I need to
perform a sub-identity on a table, I have the normal identity set,...
|
by: Thomasb |
last post by:
With a background in MS SQL Server programming I'm used to temporary
tables. Have just started to work with DB2 ver 7 on z/OS and stumbled
into the concept of GLOBAL TEMPORARY TABLE.
I have created a temporary database with a tables space. Verified that
DECLARE GLOBAL TEMPORARY TABLE TEMP (A INTEGER);
INSERT INTO SESSION.TEMP VALUES(10);
SELECT A FROM SESSION.TEMP;
works from a query tool.
|
by: Irfan |
last post by:
There are several ways of handling Transactions in DotNet. Some of them are
1. Using COM+ Serviced Component.
2. Using ADO .Net
3. using stored procedure
What is the best way of handling Transaction in DotNet Enterprise
Application interms of performance, maintainance and scalability?
How feasible it would be if we go for stored procedure option, considering
|
by: Justin |
last post by:
I am creating a web app for a client in VS.NET using ASP.NET with C#. I need
to query three tables in a database using one parameter and display the
results on the page. my question is should I use a Stored Procedure or view
in SQL Server to get the data from multiple tables? What is the difference?
and where can I find a some articles on write code to display the results of
the SP or view?
Thanks, Justin.
| |
by: comp_databases_ms-sqlserver |
last post by:
This post is related to SQL server 2000 and SQL Server 2005 all
editions.
Many of my stored procedures create temporary tables in the code. I
want to find a way to find the query plan for these procs
Repro
--***********************************
use pubs
go
CREATE PROCEDURE Test @percentage int
|
by: Otto Carl Marte |
last post by:
Hi,
As I understand it, Declared Global Temporary Tables (DGTTs) have a
scope that is session/connection based.
Using the same connection, I have discovered that if I declare a DGTT
in one stored procedure, then I can't create a second stored procedure
that uses the DGTT, as the DGTT is not "visible". The only way around
this is to use dynamic SQL in the second stored procedure. In this way
(using dynamic sql) i can create and use the...
|
by: yin_n_yang74 |
last post by:
I am new to SQL and SQL Server world. There must be a simple solution
to this, but I'm not seeing it. I am trying to create a crystal
report (v8.5) using a stored procedure from SQL Server (v2000) in
order to report from two databases and to enable parameters.
When I create the stored procedure, it joins multiple one-to-many
relationship tables. This results in repeated/duplicate records. Is
this an issue that should be solved within...
|
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...
|
by: Bogdan |
last post by:
Hi,
I have a stored procedure that uses JOINs to return columns from multiple
tables. I also have another stored proc that that takes a series of params
and updates multiple tables. I used the framework to auto-generate a table
adapter specifying both stored procs as Get/Fill and Update. The problem is
that columns from the JOINed table seem to marked as 'read-only' so trying
to update a row results in an exception. BTW, by default a...
|
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...
| |
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |