Multiple Procedures in ASP.NET

Discussion in 'ASP .Net' started by Charles, Aug 19, 2006.

  1. Charles

    Charles Guest

    I have a Web application in VB.Net that has four seperate procdedures
    which need to run in order.
    Try
    cnDownload.Open()
    Dim cmdDeleteDownload As New
    SqlCommand("ProcDeleteDownload", cnDownload)
    cmdDeleteDownload.CommandType = CommandType.StoredProcedure
    cmdDeleteDownload.ExecuteNonQuery()
    Catch ex As Exception
    sendMessage("Issue with running procDeleteDownload")
    cnDownload.Close()
    Exit Sub
    End Try
    Try
    Dim cmdDownload As New SqlCommand("ProcImportDownLoad",
    cnDownload)
    With cmdDownload
    .CommandType = CommandType.StoredProcedure
    End With
    Dim drDownload As SqlDataReader
    cmdDownload.ExecuteNonQuery()
    Catch ex As SystemException
    sendMessage("Issue with running procImport")
    cnDownload.Close()
    Exit Sub
    End Try
    Try
    Dim cmdInsertMembers As New
    SqlCommand("ProcInsertNewDownload", cnDownload)
    With cmdinsertmembers
    .CommandType = CommandType.StoredProcedure
    End With
    Dim drInsert As SqlDataReader
    cmdInsertMembers.ExecuteNonQuery()
    Catch ex As Exception
    sendMessage("Issue with running procInsertNewDownload")
    cnDownload.Close()
    Exit Sub
    End Try
    Try
    Dim cmdInsertMembers As New SqlCommand("ProcAddMembers",
    cnDownload)
    cmdInsertMembers.CommandType = CommandType.StoredProcedure
    cmdInsertMembers.ExecuteNonQuery()
    Catch ex As Exception
    sendMessage("Issue with running procAddMembers")
    cnDownload.Close()
    Exit Sub
    End Try

    Running in debug works fine but not in final release. Do I need to
    handle these statements so the code waits for each procedure to finish
    before proceding?

    Thanks
    Charles
     
    Charles, Aug 19, 2006
    #1
    1. Advertising

  2. No, because from your code sample they all appear to be blocking calls
    (nothing goes forward until the call returns).
    However, you could make it a bit more robust:

    1) get the return value from your cmdXXX methods and do something useful
    with it.
    2) you are catching exceptions but you aren't even using them, send back the
    exception Message and StackTrace in your SendMessage so you can really find
    out what's happening.
    Peter

    --
    Co-founder, Eggheadcafe.com developer portal:
    http://www.eggheadcafe.com
    UnBlog:
    http://petesbloggerama.blogspot.com




    "Charles" wrote:

    > I have a Web application in VB.Net that has four seperate procdedures
    > which need to run in order.
    > Try
    > cnDownload.Open()
    > Dim cmdDeleteDownload As New
    > SqlCommand("ProcDeleteDownload", cnDownload)
    > cmdDeleteDownload.CommandType = CommandType.StoredProcedure
    > cmdDeleteDownload.ExecuteNonQuery()
    > Catch ex As Exception
    > sendMessage("Issue with running procDeleteDownload")
    > cnDownload.Close()
    > Exit Sub
    > End Try
    > Try
    > Dim cmdDownload As New SqlCommand("ProcImportDownLoad",
    > cnDownload)
    > With cmdDownload
    > .CommandType = CommandType.StoredProcedure
    > End With
    > Dim drDownload As SqlDataReader
    > cmdDownload.ExecuteNonQuery()
    > Catch ex As SystemException
    > sendMessage("Issue with running procImport")
    > cnDownload.Close()
    > Exit Sub
    > End Try
    > Try
    > Dim cmdInsertMembers As New
    > SqlCommand("ProcInsertNewDownload", cnDownload)
    > With cmdinsertmembers
    > .CommandType = CommandType.StoredProcedure
    > End With
    > Dim drInsert As SqlDataReader
    > cmdInsertMembers.ExecuteNonQuery()
    > Catch ex As Exception
    > sendMessage("Issue with running procInsertNewDownload")
    > cnDownload.Close()
    > Exit Sub
    > End Try
    > Try
    > Dim cmdInsertMembers As New SqlCommand("ProcAddMembers",
    > cnDownload)
    > cmdInsertMembers.CommandType = CommandType.StoredProcedure
    > cmdInsertMembers.ExecuteNonQuery()
    > Catch ex As Exception
    > sendMessage("Issue with running procAddMembers")
    > cnDownload.Close()
    > Exit Sub
    > End Try
    >
    > Running in debug works fine but not in final release. Do I need to
    > handle these statements so the code waits for each procedure to finish
    > before proceding?
    >
    > Thanks
    > Charles
    >
    >
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Aug 19, 2006
    #2
    1. Advertising

  3. Charles

    Charles Guest

    Peter,

    Thanks! I will modify my exception handling as you suggested.

    Charles

    Peter wrote:
    > No, because from your code sample they all appear to be blocking calls
    > (nothing goes forward until the call returns).
    > However, you could make it a bit more robust:
    >
    > 1) get the return value from your cmdXXX methods and do something useful
    > with it.
    > 2) you are catching exceptions but you aren't even using them, send back the
    > exception Message and StackTrace in your SendMessage so you can really find
    > out what's happening.
    > Peter
    >
    > --
    > Co-founder, Eggheadcafe.com developer portal:
    > http://www.eggheadcafe.com
    > UnBlog:
    > http://petesbloggerama.blogspot.com
    >
    >
    >
    >
    > "Charles" wrote:
    >
    > > I have a Web application in VB.Net that has four seperate procdedures
    > > which need to run in order.
    > > Try
    > > cnDownload.Open()
    > > Dim cmdDeleteDownload As New
    > > SqlCommand("ProcDeleteDownload", cnDownload)
    > > cmdDeleteDownload.CommandType = CommandType.StoredProcedure
    > > cmdDeleteDownload.ExecuteNonQuery()
    > > Catch ex As Exception
    > > sendMessage("Issue with running procDeleteDownload")
    > > cnDownload.Close()
    > > Exit Sub
    > > End Try
    > > Try
    > > Dim cmdDownload As New SqlCommand("ProcImportDownLoad",
    > > cnDownload)
    > > With cmdDownload
    > > .CommandType = CommandType.StoredProcedure
    > > End With
    > > Dim drDownload As SqlDataReader
    > > cmdDownload.ExecuteNonQuery()
    > > Catch ex As SystemException
    > > sendMessage("Issue with running procImport")
    > > cnDownload.Close()
    > > Exit Sub
    > > End Try
    > > Try
    > > Dim cmdInsertMembers As New
    > > SqlCommand("ProcInsertNewDownload", cnDownload)
    > > With cmdinsertmembers
    > > .CommandType = CommandType.StoredProcedure
    > > End With
    > > Dim drInsert As SqlDataReader
    > > cmdInsertMembers.ExecuteNonQuery()
    > > Catch ex As Exception
    > > sendMessage("Issue with running procInsertNewDownload")
    > > cnDownload.Close()
    > > Exit Sub
    > > End Try
    > > Try
    > > Dim cmdInsertMembers As New SqlCommand("ProcAddMembers",
    > > cnDownload)
    > > cmdInsertMembers.CommandType = CommandType.StoredProcedure
    > > cmdInsertMembers.ExecuteNonQuery()
    > > Catch ex As Exception
    > > sendMessage("Issue with running procAddMembers")
    > > cnDownload.Close()
    > > Exit Sub
    > > End Try
    > >
    > > Running in debug works fine but not in final release. Do I need to
    > > handle these statements so the code waits for each procedure to finish
    > > before proceding?
    > >
    > > Thanks
    > > Charles
    > >
    > >
     
    Charles, Aug 19, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Elliot M. Rodriguez, MCSD

    Re: crystal reports and asp.net stored procedures

    Elliot M. Rodriguez, MCSD, May 21, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    485
    Elliot M. Rodriguez, MCSD
    May 21, 2004
  2. .Net Sports
    Replies:
    3
    Views:
    626
    Robbe Morris [C# MVP]
    May 12, 2005
  3. Hennie
    Replies:
    5
    Views:
    2,860
    Brock Allen
    Jun 4, 2005
  4. Elmo Watson
    Replies:
    4
    Views:
    428
    Elmo Watson
    Jul 24, 2007
  5. Author #1
    Replies:
    2
    Views:
    1,233
    Cowboy \(Gregory A. Beamer\)
    Apr 25, 2009
Loading...

Share This Page