CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
  1. #16
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Executing more than one stored procedure at a time

    Have SPRun() be the master, and call 3 more, each doing it's own oDR#, and call each one in sequence. Nothing is there BEFORE a form is loaded.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  2. #17
    Join Date
    Dec 2007
    Posts
    234

    Re: Executing more than one stored procedure at a time

    Assuming that all of the sprocs use the same parameter, would this work:
    Code:
     Private Sub SPRun()
            Dim oCmd2 As New System.Data.SqlClient.SqlCommand
            Dim commands as String() = {"sp_opsum", "sp_opintcheck", "sp_opexceptsum" , "sp_empsum", "sp_empexceptsum"}
            Try
                With oCmd2
                    .Connection = New System.Data.SqlClient.SqlConnection("Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx")
                    .Connection.Open()
                    .CommandType = CommandType.StoredProcedure
                    .Parameters.AddWithValue("@payperiodstartdate", payperiodstartdate)
                    .Parameters.AddWithValue("@payperiodenddate", payperiodenddate)
    for each strCommand as string in commands
                    .CommandText = strcommand
                    .Execute
    next
                    oCmd2.Connection.Close()
                End With
            Catch ex As Exception
                MessageBox.Show(ex.Message)
                oCmd2.Connection.Close()
            End Try
        End Sub
    -tg
    * I don't respond to private requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help - how to remove eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to???
    * On Error Resume Next is error ignoring, not error handling(tm). * Use Offensive Programming, not Defensive Programming.
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN
    MVP '06-'10

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured