Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Problems!

Author  Topic 

noonz
Starting Member

33 Posts

Posted - 2010-04-19 : 14:08:01
Hello all,

Ok, I will describe my problem as detailed as possible.
I have a storefront that sells coins, I would like a button that updates all the prices by one dollar.
I have created a stored procedure to update the table:

CREATE PROCEDURE D2UpdatePrices
@IncreaseAmount decimal(10,2) = NULL,
@IncreasePercent decimal(10,2) = NULL
AS
UPDATE dbo.SLProducts
SET D2ProductPrice = CASE
WHEN
@IncreaseAmount IS NOT NULL THEN D2ProductPrice + @IncreaseAmount
WHEN
@IncreasePercent IS NOT NULL THEN D2ProductPrice + (1+(@IncreasePercent/100))
ELSE D2ProductPrice
END
GO
And also a public function below:
Public Function UpdatePrices(ByVal Amount As Decimal)
Dim DBCommand As SqlCommand
DBCommand.CommandType = Data.CommandType.StoredProcedure
DBCommand.CommandText = "D2UpdatePrices"
DBCommand.Connection = DBConn
DBCommand.Parameters.Add(New SqlParameter("@IncreaseAmount", Data.SqlDbType.Decimal)).Value = Amount
DBConn.Open()
DBCommand.ExecuteNonQuery()
If DBConn.State = Data.ConnectionState.Open Then
DBConn.Close()
End If
DBConn.Dispose()
DBCommand = Nothing

End Function

I have added a button onto a page, runat="server", and here is the code for the Button1_Click :

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim NewPriceAmount As SitelockDataTransaction = New SitelockDataTransaction
Dim PriceAmount As Decimal
PriceAmount = NewPriceAmount.UpdatePrices("1")

End Sub

I put a "1" for the parameter to increase by a dollar, I will eventually be adding an InputBox to use for users to enter amounts.
I save and close everything, and go to the page in IE, every time I click the button to perform this action, it scrolls to the top of the page, and does nothing. How do I know it does nothing? I ran a SELECT * FROM dbo.SLProducts and nothing has changed with the amounts.
I have had this problem with other functions also, I click the button, it goes to the top of the page and does absolutely NOTHING, what is the problem?!?!?
Thank you!

Mike

dtecmeister
Starting Member

5 Posts

Posted - 2010-05-13 : 23:50:37
Either you're missing or left out the code that sets the parameters and performs the procedurecall.
Go to Top of Page
   

- Advertisement -