Web Hosting Talk







View Full Version : ASP help please


tuvok
06-07-2002, 09:12 AM
can anyone see whats wrong with this code, its working when the sql is met but not when it supposed to retorn resulf of zero


<%

sql = "SELECT SUM(amount) AS Total FROM payment WHERE partner_id = '" & ref_id & "' AND datex = '" & datex & "' "
set RS = DbConn.Execute(sql)
if not (RS.BOF and RS.EOF) then
Total = RS(0)
Else Total = 0
end if
Response.Write ("Total Page Hits = " & Total)

%>

mwatkins
06-07-2002, 10:04 AM
sum() returns NULL when the where condition isn't met, but I think you are getting a result set passed back, so your ELSE statement is never being executed.

Try testing RS(0) for NULL and if its NULL set Total to 0

tuvok
06-07-2002, 11:21 AM
thanks for th ereply, but that did not help either, anymore ideas anyone?

Thanx