views:

307

answers:

2
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
+3  A: 

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.

Nathan Koop
+1  A: 

hahaha! OMG. Thanks bro.

make sure to mark it as answered (check mark beside the answer)
Nathan Koop
And make sure to delete this post. The answers section should contain actual answers only. You can add this as a comment to Nathan's answer instead.
Tomalak