|
 |
access_asp thread: help Counting Number of bids placed
Message #1 by ggebre@h... on Sat, 24 Aug 2002 00:09:39
|
|
have the following Codes. what I am basically trying to do is to conunt
the number of bids which are placed on an item. From the bid program the
Item is passed through a request.querystring(ItemID) to the add bid
program which updates the database.
So far i have not been able to count the number of bids. If someone would
help I very much appreciated.
set RSItem = conn.Execute("select * From Auction where ItemID = " &
Request.QueryString("ItemID"))
Set RSItem2 = conn.execute("Select Count(NumBid = (NumBid + 1)) From
Auction Where ItemID = " _
& Request.QueryString("ItemID")) & ";"
Numbid = numbid + 1 doesn`t work.
strSQL2 = "UPdate Auction Set "_
& Request.Form("Bid") & "," _
& "`" & RSItem2("NumBid") ` here is where the error is coming from. I
removed the select statement.
Response.write strSQL2
Conn.execute strSQL2
Thanks
Gez.
Here is the entire program which adds bid to the bid table.
<%
'*************************************************************************
************************************
' Author Gez Gebre
' CSC 450 Summer 2002
' When bid is placed, it will cupture bidder information
' and inserts bidderId, Bidder name item, and bid amount into the bid
' the bids table.
'*************************************************************************
************************************
%>
<% Option Explicit %>
<%
Dim Conn
Dim RSBidder
Dim RSItem
Dim strSQL
Dim strSQL2
Dim RSBid
Dim NumBid
Dim CurrentDateTime
Dim BidAmount
Dim Bid
Dim ItemID
set Conn = server.createobject ("adodb.connection")
conn.open Application("DB_connectionstring")
If IsEmpty(Session("BidderID")) Then
Set RSBid = conn.execute("Select Max(BidderID) as
MaxID From Bidders")
Session("BidderID") = RSBID("MaxID")
End if
Set RSBidder = Conn.Execute("Select BidderName From Bidders where
BidderID = " _
& ("BidderID"))
If not IsEmpty(Request.Form ("Submit")) Then
set RSItem = conn.Execute("select * From Auction where ItemID
= " & Request.QueryString("ItemID"))
'End if
CurrentDateTime = Now
strSQL = "Insert Into Bids (BidderID, BidderName, ItemID,
BidAmount, WhenPlaced) values ("_
& Session("BidderID") & "," _
& "'" & RSBidder("BidderName") & "', " _
& "'" & Request.QueryString("ItemID") & "', " _
& "'" & Request.Form("Bid") & "', " _
& "'" & CurrentDateTime & "')"
Response.write strSQL
Conn.Execute strSQL
'Update Auction table's bid amount, and count number of bids.
'Conn.Execute
Dim CurrentBID
CurrentBid = BidAmount
strSQL2 = "UPdate Auction Set "_
& Request.Form("Bid") & "," _
& "'" & RSItem2("NumBid") ' here is where
the error is coming from. I removed the select statement.
Response.write strSQL2
Conn.execute strSQL2
End If
%>
Message #2 by "Ken Schaefer" <ken@a...> on Mon, 26 Aug 2002 13:20:54 +1000
|
|
SELECT
COUNT(Bid_Number) + 1 AS NumberOfBids
FROM
SomeTableHere
That said, I would not do it this way - since you are not using a
transaction (as far as I can see), how do you know that the number of bids
is correct? You don't, because you don't know if the next UPDATE statement
will fail.
What I would do is:
a) Do the UPDATE/INSERT first
b) Then do a COUNT() - this way you don't need to add 1 to the count that is
returned.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <ggebre@h...>
Subject: [access_asp] help Counting Number of bids placed
: have the following Codes. what I am basically trying to do is to conunt
: the number of bids which are placed on an item. From the bid program the
: Item is passed through a request.querystring(ItemID) to the add bid
: program which updates the database.
:
: So far i have not been able to count the number of bids. If someone would
: help I very much appreciated.
:
: set RSItem = conn.Execute("select * From Auction where ItemID = " &
: Request.QueryString("ItemID"))
:
: Set RSItem2 = conn.execute("Select Count(NumBid = (NumBid + 1)) From
: Auction Where ItemID = " _
:
: & Request.QueryString("ItemID")) & ";"
:
: Numbid = numbid + 1 doesn`t work.
:
: strSQL2 = "UPdate Auction Set "_
: & Request.Form("Bid") & "," _
: & "`" & RSItem2("NumBid") ` here is where the error is coming from. I
: removed the select statement.
: Response.write strSQL2
: Conn.execute strSQL2
:
:
: Thanks
:
: Gez.
:
:
: Here is the entire program which adds bid to the bid table.
:
:
:
: <%
:
'*************************************************************************
: ************************************
: ' Author Gez Gebre
: ' CSC 450 Summer 2002
: ' When bid is placed, it will cupture bidder information
: ' and inserts bidderId, Bidder name item, and bid amount into the bid
: ' the bids table.
:
'*************************************************************************
: ************************************
: %>
: <% Option Explicit %>
:
: <%
: Dim Conn
: Dim RSBidder
: Dim RSItem
: Dim strSQL
: Dim strSQL2
: Dim RSBid
: Dim NumBid
: Dim CurrentDateTime
: Dim BidAmount
: Dim Bid
: Dim ItemID
:
:
: set Conn = server.createobject ("adodb.connection")
: conn.open Application("DB_connectionstring")
:
: If IsEmpty(Session("BidderID")) Then
: Set RSBid = conn.execute("Select Max(BidderID) as
: MaxID From Bidders")
: Session("BidderID") = RSBID("MaxID")
: End if
:
: Set RSBidder = Conn.Execute("Select BidderName From Bidders where
: BidderID = " _
: & ("BidderID"))
:
: If not IsEmpty(Request.Form ("Submit")) Then
: set RSItem = conn.Execute("select * From Auction where ItemID
: = " & Request.QueryString("ItemID"))
: 'End if
:
: CurrentDateTime = Now
: strSQL = "Insert Into Bids (BidderID, BidderName, ItemID,
: BidAmount, WhenPlaced) values ("_
: & Session("BidderID") & "," _
: & "'" & RSBidder("BidderName") & "', " _
:
: & "'" & Request.QueryString("ItemID") & "', " _
: & "'" & Request.Form("Bid") & "', " _
:
: & "'" & CurrentDateTime & "')"
: Response.write strSQL
: Conn.Execute strSQL
:
: 'Update Auction table's bid amount, and count number of bids.
:
: 'Conn.Execute
: Dim CurrentBID
: CurrentBid = BidAmount
:
: strSQL2 = "UPdate Auction Set "_
: & Request.Form("Bid") & "," _
: & "'" & RSItem2("NumBid") ' here is where
: the error is coming from. I removed the select statement.
: Response.write strSQL2
: Conn.execute strSQL2
: End If
:
:
: %>
:
|
|
 |