Error with FormatNumber sentence

L

Lakrom

Hi to all
this is a Data Base in SQL Server 2000 in page cartola.asp
Good previously it asks for the date format where I only want the month in a
consultation SQL and the solution is this: f=month(date) Seth
xRs=pCon.Execute("SELECT sum(monto_abono) ace TPtosM FROM abono_gte WHERE
rutgte='"&session("rut")&"' AND month(fecha)="&f&"") but I have this
consultation in the following function:
Function TotalPuntosMes()
'// Back all point in month on curse
f= month(date)
Set pCon=server.CreateObject("adodb.connection")
pCon.Open application("StrConRuta")
Set xRs=pCon.Execute("SELECT sum(monto_abono) as TPtosM FROM abono_gte
WHERE rutgte='"&session("rut")&"' AND month(fecha)="&f&"")
If not xRs.Eof then
TotalPuntosMes=FormatNumber(xRs("TPtosM"),0,,,-2)
End if
pCon.Close
SET Pcon=Nothing
End Function
But this it throws the error to me of do not agree the types with
FormatNumber(), first think that the error is so that the field
xRs("TPtosM") null or empty can have value, but it is not the case. it is
not happened to me that it can be. I thank for of heart an aid. Thanks.
 
R

Ray Costanzo [MVP]

What is the value of xRs("TPtosM")? Can you response.write it out so you
can see? It's hard to tell why FormatNumber is failing without knowing what
exactly you're trying for format.

Ray at work
 
L

Lakrom

Thanks
i solv the problem this:
Function TotalPuntosMes()
'// Devuelve los puntos del mes en curso
f= month(date)
Set pCon=server.CreateObject("adodb.connection")
pCon.Open application("StrConRuta")
Set xRs=pCon.Execute("SELECT sum(monto_abono)as TPtosM FROM abono_gte WHERE
rutgte='"&session("rut")&"' AND month(fecha)="&f&"")
If not xRs.Eof then
TotalPuntosMes=FormatNumber(xRs("TPtosM"),0,,,-2)
else
TotalPuntosMes=FormatNumber(0,0,,,-2)
End if
pCon.Close
SET Pcon=Nothing
End Function
the problem is come when the variable take the the value null. that is all.

"Gracias a mi compañero Marcelo Moran que me abrio los ojos"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top