473,473 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

classic asp function to utilize on the recordset

120 New Member
hi guys

i'm using sql server and classic asp. I'd like to know if there is a way to apply a 10% discount or any other calculation on to my sql table that contains prices via asp on the front end??

can this be done via a asp function upon recordset retrievel? something like this?..
Expand|Select|Wrap|Line Numbers
  1. Response.Write "£" & ASPFUNCTION(objRS("Triple_Redleaf_Price")) & "
sample data
Expand|Select|Wrap|Line Numbers
  1. ID Date_Band      Redleaf_Tour  Goldleaf_Tour Double_Accomodation Triple_Accomodation Single_Accomodation Child_Accomodation Double_Redleaf_Price Double_Goldleaf_Price Triple_Redleaf_Price Triple_Goldleaf_Price Single_Redleaf_Price Single_Goldleaf_Price Child_Redleaf_Price Child_Goldleaf_Price
  2. 1  May<br />2011  Redleaf       Goldleaf      Double              Triple              Single              Child(2-11 years)  489                  989                   479                  979                   539                  1039                  419                 909
I have been told it would be better to perform this function via asp front end rather than my sql statement
http://bytes.com/topic/sql-server/an...le#post3622154

please advise

thanks in advance
Omar.
Nov 8 '10 #1
5 3391
jhardman
3,406 Recognized Expert Specialist
Yes, the function would be defined something like this:
Expand|Select|Wrap|Line Numbers
  1. function discount(listedValue)
  2.    Discount = 0.9 * listedValue
  3. End function
and the call would be just
Expand|Select|Wrap|Line Numbers
  1. response.write discount(objRS("red_leaf_price"))
Jared
Nov 8 '10 #2
omar999
120 New Member
hi jared

your above suggestion worked great.

is it however possible to apply this function to all recordset calls as a shortcut as opposed to adding the discount function to every applicable recordset call?

ideally a function that checks if rs is an integer then apply discount otherwise ignore?

thanks in advance
Omar.
Nov 8 '10 #3
jhardman
3,406 Recognized Expert Specialist
Yes, I assume you don't need advice on looping or setting up an if statement. To check the field type, try objRS("fieldName").type - this returns an integer value. I don't remember any of the individual values, but that's what I use to say "if it's a type x then do y"

Jared
Nov 9 '10 #4
omar999
120 New Member
I should be okay setting up an if loop statement.

im a bit confused as to what you mean though - do I add objRS("fieldName").type to the function?

is it not possible to avoid manually adding the function to all recordset calls and instead declaring the function once and it automatically filters through on all integer type data?

I am able to do this on the sql select statement using the cast function but it requires me to explicitly cast every applicable column. im looking for a more leaner way.

or is there an option to save the function as a stored proc and exec it from the db on to several tables?? just brainstorming here...

Omar.
Nov 9 '10 #5
jhardman
3,406 Recognized Expert Specialist
There have been several times that I have made a quick asp page to edit or add a record to a db. I typically make a form and loop through the fields putting one input in the form for each field in the db row. This usually looks like this:
Expand|Select|Wrap|Line Numbers
  1. for each x in objRS.fields
  2.    Response.write "<input type=""text"" name=" & chr(34) & x.name &  chr(34) & " value=" & chr(34) & objRS(x) & chr(34) & ">"
  3. Next
. With me so far? I often want a slightly different input for integer versus text fields. For example if I had a large text memo field I would want a textarea rather than a text input. In that case I put an if statement within the loop like this:
Expand|Select|Wrap|Line Numbers
  1. if x.type =4 then
  2.    Response.write "<textarea " 'etc
  3. Else
  4.    Response.write "<input " 'etc
  5. End if
does this make sense? This might not exactly answer your question, but this is how I would approach it.

Jared
Nov 9 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: Adam Short | last post by:
I am trying to write a routine that will connect a .NET server with a classic ASP server. I know the following code doesn't work! The data is being returned as a dataset, however ASP does not...
18
by: Darryl Kerkeslager | last post by:
When I open an ADO Recordset, I close it. However, it seems that there may be some difference in this manner of opening a Recordset: Dim rL As ADODB.Recordset Set rL = New ADODB.Recordset ...
7
by: Christian Blackburn | last post by:
Hi Gang, VB6 has a command called Date and it would not to surprisingly return the date in the following ways: Date() = 9/10/2003 Date(now) = 9/10/2003 Date("8/12/2000 12:20PM") = 8/12/2000
3
by: Ted Ngo | last post by:
I want to use the .net Web Service to create a function and return the datas (RecordSet). And want to retrived those data on the classic ASP. Does any body have some example of this. How to create...
6
by: James | last post by:
I am writing a web service for a classic ASP application. I need to consume an ADO recordset and then send it to another web service for processing. I found an MSDN ariticle telling how to do this...
6
by: InnoCreate | last post by:
Hi everyone. I've recently written a classic asp website which uses an MS Access datasource. I know this is less than an ideal data source as it has limited functionality. I have a search form on...
0
by: klove1209 | last post by:
Good afternoon. I need assistance with calling a function on the back end, that takes paremeters for a stored procedure. Then, that function returns the recordset back to the main DB. Below is the...
0
by: klove1209 | last post by:
Good afternoon. I need assistance with calling a function on the back end, that takes paremeters for a stored procedure. Then, that function returns the recordset back to the main DB. Below is the...
1
by: dayharbor | last post by:
'Splits full name into first/last name fields Private Sub SplitNames() Dim rsNames As DAO.Recordset Dim SplitName As String 'split name field strSQL = "SELECT fldName FROM...
2
by: fpennisi | last post by:
Hi all I have started writing a web app in Visual Studio 2005 (using c#). I am new to both C# and Visual Studio 2005. I will start by telling you what I need and then how I would have done it...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.