1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Procedure or function expects parameter which was not supplied

Discussion in 'C#' started by LELE7, Sep 8, 2010.

  1. LELE7

    LELE7 New Member

    Joined:
    Sep 8, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    My .Net Code
    Code:
    # connDO.Open();
    #                     SqlCommand comm = new SqlCommand("DOrders.dbo.p_Update", connDO);
    #                     comm.CommandType = CommandType.StoredProcedure;
    #                     daDirectOrders.UpdateCommand = comm;
    #  
    #     comm.Parameters.Add("@UOrderNumber", SqlDbType.Int, 32, uOrderNumber.ColumnName);
    #                     comm.Parameters.Add("@ConfirmationCode", SqlDbType.VarChar, 50, confirmationCode.ColumnName);
    #                     comm.Parameters["@ConfirmationCode"].SourceVersion = DataRowVersion.Original;
    #                     comm.Parameters.Add("@Carrier", SqlDbType.VarChar, 50, doCarrier.ColumnName);
    #                     comm.Parameters.Add("@Tracking", SqlDbType.VarChar, 50, doTracking.ColumnName);
    #                     comm.Parameters.Add("@OrderID", SqlDbType.Int, 32, orderID2.ColumnName);
    #                     comm.Parameters["@OrderID"].SourceVersion = DataRowVersion.Original;
    #                     comm.Parameters.Add("@LineItem", SqlDbType.Int, 32, lineItem.ColumnName);
    #                     comm.Parameters["@LineItem"].SourceVersion = DataRowVersion.Original;
    #  
    #                     daDirectOrders.Update(dataSet);
    #                     connDO.Close();
    
    My Stored Procedure:

    Code:
    #  @UOrderNumber int,
    #     @ConfirmationCode varchar(50),
    #     @Carrier varchar(50),
    #     @Tracking varchar(50),
    #     @OrderID int,
    #     @LineItem int
    #  
    # AS
    # BEGIN
    #  
    #     SET NOCOUNT ON;
    #  
    #     UPDATE Orders 
    #         SET UOrderNumber = @UOrderNumber
    #         WHERE ConfirmationCode = @ConfirmationCode
    #  
    #     UPDATE OrdersDetail
    #         SET Carrier = @Carrier, Tracking = @Tracking, LastUpdated = GETDATE()
    #         WHERE OrderID = @OrderID and LineItem = @LineItem
    #  
    #  
    # END
    
    When I run, I get the following error:

    Procedure or function 'p_update' expects parameter '@Carrier' which was not supplied

    Why isn't is recognizing my parameter? Also, it does not give a problem with @UOrderNumber and @ConfirmationCode. And when I do Parameters.AddWithValue and pass a string value, it does work. The problem is, that my value has to be a dataColumn from my dataset and addWithValue does not take a dataColumn from what I saw. (correct me if I'm wrong)

    Thanks!
     

Share This Page