473,395 Members | 2,079 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.

DataGrid + Stored Procedure Problem

Hi,
Question regarding displaying data on Datagrid. it works fine
I have 4 SP's the results of which I feel are too much overhead. so I put
all the 4 queries into as single STP and it runs successfully but only the
first one is bound for eg:

Create PROCEDURE dbo.Sample
(
@id int,
}
as
Select * from Sample1 where id = @id
Select * from Sample2 where id = @id

GO

why does it not append/display the entire resultset?
Thanks,
Stephen
Nov 19 '05 #1
2 1037
You have two result sets is why. (If you where pulling this data with a
datareader, you would have to use the NextResult method to access it).

http://msdn2.microsoft.com/en-us/lib...der.nextresult

I believe to get the results you want you need to use UNION ALL

Select * from Sample1 where id = @id
UNION ALL
Select * from Sample2 where id = @id

UNION ALL is not as efficient as just UNION (if I'm remembering correctly),
but I think it is requried if you have the exact same data coming from both
selects statements and you want it to be included.

STP? is that short for stored procedure (aka sproc)?

Greg

"Stephen" <st********@hotmail.com> wrote in message
news:eC****************@TK2MSFTNGP11.phx.gbl...
Hi,
Question regarding displaying data on Datagrid. it works fine
I have 4 SP's the results of which I feel are too much overhead. so I put
all the 4 queries into as single STP and it runs successfully but only the
first one is bound for eg:

Create PROCEDURE dbo.Sample
(
@id int,
}
as
Select * from Sample1 where id = @id
Select * from Sample2 where id = @id

GO

why does it not append/display the entire resultset?
Thanks,
Stephen

Nov 19 '05 #2
Greg,
Thanks for the info
stephen

"Greg Burns" <bl*******@newsgroups.nospam> wrote in message
news:%2******************@TK2MSFTNGP14.phx.gbl...
You have two result sets is why. (If you where pulling this data with a
datareader, you would have to use the NextResult method to access it).

http://msdn2.microsoft.com/en-us/lib...der.nextresult
I believe to get the results you want you need to use UNION ALL

Select * from Sample1 where id = @id
UNION ALL
Select * from Sample2 where id = @id

UNION ALL is not as efficient as just UNION (if I'm remembering correctly), but I think it is requried if you have the exact same data coming from both selects statements and you want it to be included.

STP? is that short for stored procedure (aka sproc)?

Greg

"Stephen" <st********@hotmail.com> wrote in message
news:eC****************@TK2MSFTNGP11.phx.gbl...
Hi,
Question regarding displaying data on Datagrid. it works fine
I have 4 SP's the results of which I feel are too much overhead. so I put all the 4 queries into as single STP and it runs successfully but only the first one is bound for eg:

Create PROCEDURE dbo.Sample
(
@id int,
}
as
Select * from Sample1 where id = @id
Select * from Sample2 where id = @id

GO

why does it not append/display the entire resultset?
Thanks,
Stephen


Nov 19 '05 #3

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

Similar topics

1
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple...
5
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
6
by: Jim | last post by:
Can someone, please, show me how to display the results of a stored procedure in a VB.NET datagrid on a winform? I'm a newbie. Here's my SQL 2000 stored precedure that returns the status of...
1
by: chreo | last post by:
Hello. Does anybody had problem with VB application with MS SQL Database? I have DATAGRID which shows TABLE from DATABASE. Next I add new ROW to TABLE with SQLcommand (stored procedure) ...
3
by: thebison | last post by:
Hi all, I hope someone can help with this relatively simple problem. I am building a timesheet application using ASP.NET C# with Visual Studio 2003.As it is only a protoype application, my...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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...

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.