Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

field sum

Status
Not open for further replies.

evr72

MIS
Dec 8, 2009
265
US
Hello,

I have a dynamic field

Code:
<% =(Recordset1.Fields.Item("id").Value)%>

this field is numeric. Is there a way that I could add 1 to the field, for example if the field is 10, show 11 or if it is 522 show 523?

Thank you
 
Put it into de convert-to-double function and add 1:
Code:
<% = Cdbl((Recordset1.Fields.Item("id").Value)) + 1 %>


?




 
Or drop it into a variable.
Code:
<%
myvalue = Recordset1.Fields.Item("id").Value
response.write myvalue + 1
%>
 
... or simly add 1 in the SQL query already! (if you need to retrieve a lot of records and display them on 1 screen, that would be the fastest).


 
that would be the fastest

Me thinks you're splitting hairs here. How many +1 math operations does it take for the time to become measurable?



-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
How many +1 math operations does it take for the time to become measurable? "


That number will vary depending on the DBMS used. A tiny test program and an MS-ACCESS database shows already with 2000 records a measurable difference.

I agree completely that nobody probably would put 2000 records on a page, but DBMS calculations *are* faster. So if for example you have more than 1 calculation (especially more complex then just adding), that 2000 number will be less lower...
 
Since we're talking about ASP here, we also need to consider where we want to put that load.

We have two main components we are dealing with here. IIS to process the web page request, and the database engine itself. In a "busy" environment, these two components would likely be on separate computers/servers. So, the real question (in my opinion) becomes, which component/computer do we want to add the work to? The database engine or the IIS machine?

By the way... I suspect that most of the time is spend converting from a variant (the base type that ASP uses) to a double, and then to a string (used to display the text). When you do this on the database end, the type conversions don't exist.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top