1
ALTER PROCEDURE dbo.uspGetOrderTrackingHeaderInfo
  @ContractID varchar(9)
, @SalesRepID int
, @StatusID int
, @TypeID int
, @StartDate datetime
, @EndDate datetime
, @Identity int = null output

AS

INSERT INTO [dbo].[tblOrderTracking]
           ([ContractID]
           ,[StatusID]
           ,[TypeID]
           ,[SalesRepID]
           ,[StartDate]
           ,[EndDate])
     VALUES
           (@ContractID
           ,@StatusID
           ,@TypeID
           ,@SalesRepID
           ,@StartDate
           ,@EndDate)


SET @Identity = Scope_Identity()

Using oConn As New SqlConnection(Me.Master.Master.AdminNetConnString)
        Try
            With cmd
                .Connection = oConn
                .CommandType = CommandType.StoredProcedure
                .CommandText = "dbo.uspInsertOrderTrackingInfo"
                .Parameters.AddWithValue("@ContractID", Session("@OrderContractID"))
                .Parameters.AddWithValue("@SalesRepID", Integer.Parse(Me.ddlSalesRep.SelectedValue.ToString()))
                .Parameters.AddWithValue("@StatusID", Integer.Parse(Me.ddlStatus.SelectedValue.ToString()))
                .Parameters.AddWithValue("@TypeID", Integer.Parse(Me.ddlOrderType.SelectedValue.ToString()))
                .Parameters.AddWithValue("@StartDate", CDate(txtStartDate.Text.Trim))
                .Parameters.AddWithValue("@EndDate", CDate(txtEndDate.Text.Trim))
                .Parameters.Add("@Identity", SqlDbType.Int, ParameterDirection.Output)
            End With

            oConn.Open()

            cmd.ExecuteNonQuery()
            Session("WorkingOrderID") = cmd.Parameters("@Identity").Value

            Response.Redirect("OrderOverview.aspx")
        Catch ex As Exception
            Me.Master.Master.HandleException(ex, True, "An error occured while attempting to save the order setup information")
        Finally
            If Not cmd Is Nothing Then
                cmd.Dispose()
            End If
        End Try
    End Using
1
  • 1
    Just a note that you can add your cmd object to the using statment as well. Then let the calling method handle any exceptions. Commented Apr 24, 2009 at 15:28

1 Answer 1

3

You have posted code for the proc "uspGetOrderTrackingHeaderInfo" and you are calling the proc "uspInsertOrderTrackingInfo". Perhaps you have modified the wrong proc and don't have the output on the Insert one.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.