The following ASP script is used to make a new bid. The information required for the new bid is passed to the server as URL query parameters. The script first checks to make sure that the bid is valid and that no one else has beaten the bidder with a higher bid already. If the bid is valid, the script updates the bid table with a new row and returns an XML formatted result. The client will then request an update using UPDATE.ASP.
<%@ LANGUAGE = VBScript %> <% ' Process the submission of a single bid. title = Request.QueryString("title") price = Request.QueryString("price") bidder = Request.QueryString("bidder") Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open "Auction","sa","" Set BidRS = Conn.Execute("select * from bids3 where Title equals '" & title & "' ORDER BY Price DESC") BidRS.MoveFirst valid = true if Not BidRS.EOF then currentprice = BidRS("Price") if (currentprice >= CLng(price)) then valid = false bidder = BidRS("bidder") end if end if if (valid) then Set RS = Server.CreateObject("ADODB.RecordSet") connect = "data source=Auction;user id=sa;password=;" RS.CursorType = 2 RS.LockType = 3 ' read/write RS.Open "bids3", connect RS.AddNew RS("title") = title RS("price") = price RS("bidder") = bidder RS("time") = Time RS.Update RS.Close %> <OK>ok</> <% else %> <ERROR>Your bid was beaten by '<%=bidder%>'</> <% end if %>
Back to the XML Auction Demo overview.
© 1997 Microsoft Corporation. All rights reserved. Terms of use.