473,498 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

nextresult

i want to execute 2 stored procs and get teh result using nextresult.
this gives me an error

sqlCommand.CommandText ="spProc1; spProc2";

is that possible to execute 2 stored procs or can we just execute 2 or more
sql statements
and use nextresult on it?

thnx
Nov 16 '05 #1
1 2860
2 statements inside one stored proc will work.
You can embed the two proc call in a third proc - this way you'll get the
result from both of them with one call to ExecuteReader.

The reason for two procs not working at once, is becouse of the fact that
when you execute the stored proc, ADO.NET passes a "exec [procname] [@params
list]" to SQL. So when you call "sp_proc1; sp_proc2" or something like this,
it sends "exec sp_proc1; proc2" which is not a valid command according to
SQL :)

There is another option, of you still want to execute the procs from the
code, and in a batch.
It will be a little slower, but will work. Here is the solution:

Use the following command text: "exec spProc1; exec spProc2". Then DON'T SET
the CommandType to stored proc.

Cheers,
Branimir

--
Branimir Giurov
MCSD.NET, MCDBA, MCT
eAgility LLC

"frazer" <ic***@hotmail.com> wrote in message
news:ep**************@TK2MSFTNGP10.phx.gbl...
i want to execute 2 stored procs and get teh result using nextresult.
this gives me an error

sqlCommand.CommandText ="spProc1; spProc2";

is that possible to execute 2 stored procs or can we just execute 2 or more sql statements
and use nextresult on it?

thnx

Nov 16 '05 #2

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

Similar topics

3
3036
by: Marcel | last post by:
Hello, I'm working on a search application for my website. The website contains a lot of pictures, and a search should return clickable thumbnails. No problems there. My problem started when I...
6
11841
by: lakshmi | last post by:
Hi all I'm trying to traverse through the results from a query that returns more than 1 row. The data reader reads only the first row. The following code doesn't work. Let me know what's wrong....
3
4368
by: Arjen | last post by:
Hello, With my SqlDataReader I select 2 records. Here is a little bit of my code: SqlDataReader dr = documents.GetDocuments(ModuleId); // Load first row into Datareader if (dr.Read()) {...
1
6800
by: T8 | last post by:
I have a asp.net (framework 1.1) site interfacing against SQL 2000. It runs like a charm 99% of the time but once in a while I get the following "unspecified error". Sometimes it would resolve by...
4
4691
by: Patrick Olurotimi Ige | last post by:
I have a DropDown Lsit set to ddlGetDebtor.Items.Insert(0, "-Select Debtor Code-") which is setting the "-Select Debtor Code-" to be default And on PostBack i'm passng:- Cmd.Parameters.Add(New...
1
1102
by: Patrick Olurotimi Ige | last post by:
Hi DevGuy thx for the reply but using:- Cmd.Parameters.Add(New SqlParameter("@DebtorCodeID", > ddlGetDebtor.SelectedItem.Value.ToString)) Still give the same error!!! Whereas Charmis advice...
2
3381
by: orencs | last post by:
Hi, I am using Datareader and stored procedure in C# ADO.NET. When I am running the stored procedure in the SQL Query Analyzer and recieve two rows (as I hace expected) col1 col2 0 1 0 ...
10
2053
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm using this coding to get 2 resultsets thru datareader and then load them into 2 datatables and bind the datatables to datagridviews. But sdrGrid.NextResult() is returning false for some...
0
662
by: Aashish Upadhyay | last post by:
Hi friends, I am trying to use NextResult method while Connecting my console based application with MS Access database but there is an error generated at run timeit says "Syntax error in from Clause"...
0
7165
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,...
1
6887
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
5462
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,...
1
4910
isladogs
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...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
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...

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.