locked
Cant Get Update Store Procedure to work with SqlDatasource RRS feed

  • Question

  • User-1046621233 posted

    Hey

    I would like to know if someone can help me please

    I'm trying to update a datatable with a sqldatasource control, I have 2 parameters conditions in my where clause , but I cant seem to get this to work , Im getting an error :   Input string was not in a correct format.

    Can someone please help me, I would seriously appreciate your help

    html (below)

    ----------------------------------------------------------------------------

     <asp:SqlDataSource ID="SQLDatasource2" runat="server"
                ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
                          
                
                UpdateCommand="Update_ProductUSERBrowsingHistory_byProductID" UpdateCommandType="StoredProcedure"  >

                
                <UpdateParameters>

                <asp:Parameter Name="ProductID" Type="Int32" />
                     <asp:Parameter Name="OrderClientIPAddress" Type="String" />
                <asp:Parameter Name="DeleteNotVisible"  Type="Boolean" />
              
                      
                </UpdateParameters>
                </asp:SqlDataSource>   

    -------------------------------------------------------------

    codebehind (below)

    ----------------------------------------------------------

    on button click event

            SQLDatasource2.UpdateParameters(0).DefaultValue = "701"
            SQLDatasource2.UpdateParameters(1).DefaultValue = HiddenIPAddress.Value
            SQLDatasource2.UpdateParameters(2).DefaultValue = "True"
            SQLDatasource2.Update()

    ----------------------------------------------------------

    SQL Store Procedure (below)

    ----------------------------------------------------------

    alter PROCEDURE [dbo].[Update_ProductUSERBrowsingHistory_byProductID]
    (
     @ProductID int,
     @OrderClientIPAddress varchar(20),
    @DeleteNotVisible bit
    )
    AS
        SET NOCOUNT ON;
    UPDATE [ProductViewAmount] SET [DeleteNotVisible] = @DeleteNotVisible


    WHERE (ProductID=@ProductID) and OrderClientIPAddress=@OrderClientIPAddress

    --------------------------------------------------------------------------------

    Thank you for helping, I seriously appreciate your help, time and effort

    Regards

    Jake



    Thursday, August 25, 2011 5:22 PM

Answers

  • User596829554 posted

    SQLDatasource2.UpdateParameters(2).DefaultValue = "True"

    my initial assessment is that you're not passing this into the right arugment. Try using 1 or true without the quotes.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 25, 2011 9:54 PM

All replies

  • User596829554 posted

    SQLDatasource2.UpdateParameters(2).DefaultValue = "True"

    my initial assessment is that you're not passing this into the right arugment. Try using 1 or true without the quotes.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 25, 2011 9:54 PM
  • User-1046621233 posted

    Hey

    Thank you, I got this to work :)

    Regards

    Jake

    Friday, August 26, 2011 5:56 AM