473,503 Members | 1,687 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to execute more than one stored procedure at a time?

347 Contributor
I have a form that requires me to execute several stored procedures one after the other. I'm wondering how to do that in vb.net. I realize that I could just have one stored procedure with all of my queries in it, but for clarities sake, I want to keep them seperate.

Thank you

Doug
Jan 21 '11 #1
2 1602
yarbrough40
320 Contributor
Expand|Select|Wrap|Line Numbers
  1. sql = "EXEC sp_1;EXEC sp_2;EXEC sp_3"
Jan 27 '11 #2
dougancil
347 Contributor
yarbrough,

I tried that and could never seem to get the sp's to execute. I have instead gone with this:

Expand|Select|Wrap|Line Numbers
  1.  Dim oCmd2 As System.Data.SqlClient.SqlCommand
  2.         Dim oDr2 As System.Data.SqlClient.SqlDataReader
  3.         oCmd2 = New System.Data.SqlClient.SqlCommand
  4.         Try
  5.             With oCmd2
  6.                 .Connection = New System.Data.SqlClient.SqlConnection("Initial Catalog=mdr;Data Source=1xxxxx;uid=xxxxx;password=xxxxx")
  7.                 .Connection.Open()
  8.                 .CommandType = CommandType.StoredProcedure
  9.                 .CommandText = "exec sp_opsum @payperiodstartdate = " + payperiodstartdate + ",@payperiodenddate=" + payperiodenddate + ";" + _
  10.  "exec sp_opintcheck @payperiodstartdate = " + payperiodstartdate + ",@payperiodenddate=" + payperiodenddate + ";" + _
  11.  "exec sp_opexceptsum @payperiodstartdate = " + payperiodstartdate + ",@payperiodenddate=" + payperiodenddate + ";" + _
  12.  "exec sp_empsum @payperiodstartdate = " + payperiodstartdate + ",@payperiodenddate=" + payperiodenddate + ";" + _
  13.  "exec sp_empexceptsum @payperiodstartdate = " + payperiodstartdate + ",@payperiodenddate=" + payperiodenddate + ";"
  14.                 oDr2 = .ExecuteReader()
  15.                 oCmd2.Connection.Close()
  16.             End With
  17.         Catch ex As Exception
  18.             MessageBox.Show(ex.Message)
  19.             oCmd2.Connection.Close()
  20.         End Try
  21.         SPRun()
  22.  
which still doesnt work
Jan 27 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
3933
by: JS | last post by:
I have v8.1 fix 5 installed on windows 2k. I compiled a stored procedure in development environment, then used the get routine command to generate the file. I transferred the file to second test...
1
1121
by: Peri | last post by:
Dear All, Can you one give me some sample code for connecting to the SQL server DB and executing a stored procedure in the SQL server using ASP.NET ? I also need to display the result set in...
3
3458
by: kd | last post by:
Hi All, How to debug a stored procedure? Thanks, kd
1
1454
by: A1 Ronen | last post by:
Hi all I got problem regarding executing all stored procedure through common procedures where we have different parameter with different names, type and data type The Function is as follows...
5
2033
by: Daniel | last post by:
will a client application using ado.net get an exception if the command is executing a stored procedure that does a RAISEERROR in its tsql?
4
2454
by: Mikael.Bergstrand | last post by:
I can't execute my stored procedure from .NET (I think it might be because the stored proc has joins in it via linked servers). I get timeout error from .NET MyBase.connString ="Integrated...
2
2307
by: vvenk | last post by:
Hello: I wrote a test procedure on Oracle that returns a string and a value. CREATE OR REPLACE PROCEDURE EBMS.p_CSV_Upload ( P_ERROR OUT VARCHAR2, P_ERROR_NO ...
2
6726
by: moforiappiah | last post by:
I urgently need help on how to execute a stored procedure in SQL Express 2005. I have created a stored procedure with as follows: Create Procedure upInsertCountry @CountryName varchar(50) ...
4
2965
by: jleeie | last post by:
Can someone help me, I'm going round in circles with this and my head is cabbaged ! I am using visual studio 2005 & VB & MS SQL 2005 I am trying to execute a stored procedure from within a...
3
3489
by: saurabh9gupta | last post by:
I have a silverlight web page on which I have a button which updates the values in the database. On the click of the button I want to execute the update query to update the table. I am not...
0
7086
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
7280
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
6991
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
5578
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
5014
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
4673
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...
0
3167
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
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
382
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.