473,799 Members | 3,298 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 1619
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
3959
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 environment with same fixpack level, but no compiler or development environment installed. I issued put routine in second test environment and command succeeded but when i try and run the stored proc with call command, db2 comes back with sql0444...
1
1139
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 the datagrid. Can anyone help me out with a sample code ? Thanks and Regards,
3
3479
by: kd | last post by:
Hi All, How to debug a stored procedure? Thanks, kd
1
1473
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 Where strProcString is procedure name and strParamString is all parameters concatenated by @
5
2048
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
2474
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 Security=SSPI;Persist Security Info=False;Initial Catalog=DB;Data Source=Server;" MyBase.selectString = "Exec sp_storedprocedure1 var1,var2,var3" MyBase.GetDataSet()
2
2327
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 OUT Number ) AS
2
6747
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) INSERT INTO CountryTable (CountryName) VALUES (@CountryName) When run the following code :
4
2993
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 program. I want to return values. I can get a 0 or 1 returned. I don't seem to be able to get any other value returned. below is my VB code and the stored procedure. I would really appreciate if someone would have a look that knows how to do this....
3
3502
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 getting any clue on how to go on with. Please suggest something
0
9688
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, 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...
0
10490
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
10030
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
9078
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
6809
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();...
0
5467
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5590
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
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 we have to send another system
3
2941
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.