I have database with tables 

* `dbo.auctions` : `[id]` `[productid]` `[lastbider]` `[bidvalue]` `[lastbid]`
* `dbo.products` : `[id]` `[name]`
* `dbo.users` : `[id]` `[name]` `[password]` `[bids]`

I need to write a procedure that checks if `[bids]` are more than 0. 

If it is, `[lastbid]` is updated and `[bidvalue]` is added to it, something like `lastbid = lastbid + bidvalue`, and `[bids]` are lowered by 1, `bids = bids - 1`. And I need to connect that to `Button` in `Visual Studio`.

I wrote this procedure:

```
ALTER PROCEDURE [dbo].[usp_makebid] (
    @userid int, @auctionid int
)

 AS
DECLARE @bids int, @lastbid int
SELECT @bids = COUNT (*)
FROM users
WHERE users.id = @userid

IF @bids > 0
BEGIN
    UPDATE auctions
    SET lastbid = @lastbid + bidvalue
    WHERE id = @auctionid
        AND lastbid = @lastbid
    UPDATE users
    SET bids = @bids - 1
    WHERE bids = @bids
    END

```

and connected it to `Button` : 

```
protected void Button1_Click(object sender, EventArgs e)
{

        using (var con = new SqlConnection(@"data source=JOVAN-PC;database=aukcija_jovan_gajic;integrated security=true"))
        {
            con.Open();
            var userid = 1;
            var auctionid = 2;

            var cmd = new SqlCommand("usp_makebid", con);
            cmd.Parameters.AddWithValue("@userid", userid);
            cmd.Parameters.AddWithValue("@auctionid", auctionid);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.ExecuteNonQuery();
            con.Close();
    }
}

```

but when I click on the button, nothing happens.

Main page looks like this, maybe that can give you general idea :

[![enter image description here](https://i.stack.imgur.com/u2SlJ.jpg)](https://i.stack.imgur.com/u2SlJ.jpg)