473,425 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,425 software developers and data experts.

currency conversion on retrieve record from sql table using asp

120 100+
I have a sql table containing GBP prices and I was wondering if there is a way to pull out these prices, convert them to EURO prices and then to display them on a webpage as EURO prices?

is this even possible?

p.s I dont have a problem pulling out the prices using asp/sql - I just need to know if they can be converted and pulled out as I would prefer to avoid creating multiple tables.

my code
Expand|Select|Wrap|Line Numbers
  1. <%
  2. 'DISPLAY PRICES
  3. DIM objConn19and20
  4. Set objConn19and20 = MYCONNGOESHERE
  5.  
  6. DIM FLIGHTROUTES19and20
  7. FLIGHTROUTES19and20 = "SELECT * FROM MYTABLENAMEGOESHERE
  8.  
  9. DIM objRS19and20
  10. Set objRS19and20 = MYCONNGOESHERE
  11.  
  12. If objRS19and20.Eof Then 
  13. 'This checks to see if we are at end of file (eof) for the returned recordset
  14. 'if we are there were no records we tell them that
  15. Response.write "<div align='center'>Sorry there are no current records.</div>" 
  16. Else 
  17.  
  18. Response.Write "<table align=""center"" id=""flightspecialscontainer"" cellpadding=""0"" cellspacing=""0"">"
  19. Response.Write "<tr><td>"
  20.  
  21. 'start a loop that will go until the eof
  22. Do while not objRS19and20.Eof 
  23.  
  24. 'if there were records lets do something with them
  25. 'write some table setup
  26. Response.Write "<table align=""center"" cellpadding=""0"" cellspacing=""0"" id=""flightspecialroutetable"">"
  27. Response.Write "<tr><td>" & objRS19and20("Anchor_Tag") & vbCrLf & "<fieldset class=""fieldsetspecialpricebox"">" & vbCrLf
  28. Response.Write "<legend>" & vbCrLf & "<span class=""specialtitlesmall"">" & objRS19and20("Flight_Route") & "</span>" & vbCrLf & "</legend>" & vbCrLf
  29. Response.Write "<table align=center cellpadding=0 cellspacing=0 class=""specialpricetable"">" & vbCrLf
  30. Response.Write "<tr>" & vbCrLf & "<td class=""priceheadertd"">Price</td>" & vbCrLf
  31. Response.Write "<td class=""dateheadertd"">Outbound Date/s</td></tr>" & vbCrLf
  32. Response.Write "<tr><td colspan=2 height=10>&nbsp;</td></tr>" & vbCrLf
  33.  
  34. 'write your table content
  35. Response.Write "<tr>" & vbCrLf & "<td class=""pricetd"">&pound;" & objRS19and20("Price_Band_1") & "</td>" & vbCrLf
  36. Response.Write "<td class=""datetd""><span class=""monthspan"">" & objRS19and20("Month_Band_1") & "&nbsp;</span>" & objRS19and20("Date_Band_1") & "</td>" & vbCrLf & "</tr>" & vbCrLf
  37. Response.Write "<tr>" & vbCrLf & "<td class=""pricetd"">&pound;" & objRS19and20("Price_Band_2") & "</td>" & vbCrLf
  38. Response.Write "<td class=""datetd""><span class=""monthspan"">" & objRS19and20("Month_Band_2") & "&nbsp;</span>" & objRS19and20("Date_Band_2") & "</td>" & vbCrLf & "</tr>" & vbCrLf
  39. Response.Write "<tr>" & vbCrLf & "<td class=""pricetd"">&pound;" & objRS19and20("Price_Band_3") & "</td>" & vbCrLf
  40. Response.Write "<td class=""datetd""><span class=""monthspan"">" & objRS19and20("Month_Band_3") & "&nbsp;</span>" & objRS19and20("Date_Band_3") & "</td>" & vbCrLf & "</tr>" & vbCrLf
  41. Response.Write "<tr>" & vbCrLf & "<td class=""pricetd"">&pound;" & objRS19and20("Price_Band_4") & "</td>" & vbCrLf
  42. Response.Write "<td class=""datetd""><span class=""monthspan"">" & objRS19and20("Month_Band_4") & "&nbsp;</span>" & objRS19and20("Date_Band_4") & "</td>" & vbCrLf & "</tr>" & vbCrLf
  43.  
  44. 'end table setup
  45. Response.Write "<td colspan=""2"" class=""specialbookbuttontd""><a class=""button"" href=""#BackToTop"" onClick=""change_booking(" & objRS19and20("Book_Button") & ")"">BOOK NOW !</a></td>"
  46. Response.Write "</tr>" & vbCrLf & "</table>" & vbCrLf & "</fieldset>"  & vbCrLf
  47. Response.Write "</td></tr></table>" & vbCrLf & vbCrLf
  48.  
  49. 'move to the next record in the recordset
  50. objRS19and20.movenext
  51.  
  52. Loop 
  53.  
  54. end if 
  55.  
  56. 'close out your table
  57. Response.Write "</td>" & vbCrLf & "</tr>" & vbCrLf & "</table>" & vbCrLf
  58.  
  59. objRS19and20.Close
  60. Set objRS19and20 = Nothing
  61. objConn19and20.Close
  62. Set objConn19and20 = Nothing
  63. %>
  64.  
thanks in advance,
Omar.
Mar 25 '10 #1
5 2655
nbiswas
149 100+
Hi, you need to write a function either at your backend application or in your frontend application that will convert the INR to EURO.

e.g. 1 Indian rupee = 0.0164715581 Euros (As per 26th March, 2010).

Since we know that, the denomination does not always remain constant, so according to me kindly find a web service and consume that from your client application. So that you don't have to worry about the exact rate when there will be a fluctuation in denomination.

I found some for you . Have a look

a) CurrencyConvertor

b) Noon Foreign Exchange Rates Web Service

Hope this will help you
Mar 26 '10 #2
omar999
120 100+
hey nbiswas

thanks for your reply. i understand what you are saying although i think i need to focus on how to convert the gbp to euro from the front end side for now.

a backend web services integration can be step 2 although i agree with an automated web services feeding the latest currency conversion rate : ) thank you for providing the 2 examples of web services/currency converters but I need to speak to my superiors regarding their sources of currency exchange but thats step 2.

could you advise how I could perform a simple conversion on the front end from the sql statement please?

my table is something like this
ID.....Route........................Month......Dat e_Band_1.......Price_Band_1
1..........Gatwick to Toronto.....March.......13,14..................... .449

thanks in advance
regards
Omar.
Mar 26 '10 #3
nbiswas
149 100+
We know that, 1 British pound (GBP)= 1.11541632 Euros (March 26th, 2010)

So the select query will be

select Id, Route,Month,Date,Band_1, EuroPrice = Cast( Price_Band_1 * 1.11541632 as Varchar(100)) + space(1) + 'Euros' from tblInfo
Mar 26 '10 #4
omar999
120 100+
thanks - I've got this error 'Arithmetic overflow error converting varchar to data type numeric.' when I used
Expand|Select|Wrap|Line Numbers
  1. select ID, Price_Band_3 = Cast( Price_Band_3 * 1.11541632 as Varchar(50)) from TABLENAME WHERE ID='1'
  2.  

although this works
Expand|Select|Wrap|Line Numbers
  1. select ID, Price_Band_3 = Cast( Price_Band_3 * 2 as int) from TABLENAME WHERE ID='1'
  2.  
not sure why im getting an error as Price_Band_3 = 109 on ID=1 on my table?
Mar 26 '10 #5
omar999
120 100+
i still have this error .. can anyone help please?
Apr 3 '10 #6

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

Similar topics

4
by: Chris | last post by:
Hi, I am going to be difficult here... How do I retrieve one row at a time from a table without using a cursor? For example, I have a table with 100 rows. I want to retrieve the data from...
2
by: Willing 2 Learn | last post by:
I'm still having trouble getting my program to do arithmetic in cents(keeping all #'s) then convert the answer in a format of dollars & cents. The main program should add, subtract, scalar...
4
by: digitalavatar | last post by:
I am having a problem with my Access 2000 front end to a SQL 7 or 2000 database. I create a table in SQL with a field named, say, amt, data type MONEY. When I link the table in Access using ODBC,...
5
by: Manuel Canas | last post by:
Hi there, I have a form with a couple of tabs on in and I'm filling the form from a dataset with the fill method. I am using a currency manager for binding controls with a datatable....
1
by: Manuel Canas | last post by:
I'm stuck here guys, need some help. I have a form with a couple fo tabs on it. I load a table in each for each tab. I populate a listbox with a list of names. Then I use currency manager to...
2
by: sck10 | last post by:
Hello, I have a SQL Server 2K table with a field set to currency. When I try to insert or update a FormView, I get the following error: Disallowed implicit conversion from data type nvarchar...
13
by: kev | last post by:
Hi all, I have created a database for equipments. I have a form to register the equipment meaning filling in all the particulars (ID, serial, type, location etc). I have two buttons at the end...
16
by: xjohnx | last post by:
Hi, I'm hoping someone can help me I am quite new to Javascript and have had to create a programme which converts dollars into euros and vice versa, here is my script which is working var...
0
by: =?Utf-8?B?RGVuaXMgU29oZXQ=?= | last post by:
Hi all, I've created a new project to test ObjectDataSource component. I've just added a new objectdatasource, configured it (linked to a table) etc ... It works fine on localhost, i can...
25
by: mereba | last post by:
Hello My country Ghana is changing its currency. I want to write a small programme in C++ that can covert from the old currency into the new one. I would like this programme to run behind a simple...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
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: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
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...

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.