Is there a functionality or a third party software that helps me display currency exchange rates in my .net webapplication? It is a requirement in my current project.
You will need to purchase a currency feed (normally in xml format) and they cost in the region of £500 GBP per year (although you might get cheaper ones). You can then access this feed a limited number of times per day. What you will need to do as a result
is create an application that makes a call to the feed once a day and then parse the xml document for inserting into your db. Once there, you web app will be able to display the rates to your users.
Public Shared Function Convert(amount As Decimal, fromCurrency As String, toCurrency As String) As Decimal
Try
Dim web As New WebClient()
Dim url As String = String.Format("http://www.google.com/ig/calculator?hl=en&q={2}{0}%3D%3F{1}", fromCurrency.ToUpper(), toCurrency.ToUpper(), amount)
Dim response As String = web.DownloadString(url)
Dim regex As New Regex("rhs: ""(?<To>[0-9.\s]+)(.*?)""")
Dim match As Match = regex.Match(response)
Dim rate As Decimal = System.Convert.ToDecimal(regex.Replace(match.Groups(2).Value, "[^\w'\.""&:;-]+", ""))
Return rate
Catch generatedExceptionName As System.OverflowException
Return generatedExceptionName.Message.ToString
Catch generatedExceptionName As System.FormatException
Return generatedExceptionName.Message.ToString
Catch generatedExceptionName As System.ArgumentNullException
Return generatedExceptionName.Message.ToString
End Try
End Function
afache
Member
203 Points
497 Posts
Determining exchange rates in .net
Sep 25, 2009 07:56 AM|LINK
Hi,
Is there a functionality or a third party software that helps me display currency exchange rates in my .net webapplication? It is a requirement in my current project.
Thanks
Mark DotNet ...
Participant
847 Points
190 Posts
Re: Determining exchange rates in .net
Sep 25, 2009 10:50 AM|LINK
You will need to purchase a currency feed (normally in xml format) and they cost in the region of £500 GBP per year (although you might get cheaper ones). You can then access this feed a limited number of times per day. What you will need to do as a result is create an application that makes a call to the feed once a day and then parse the xml document for inserting into your db. Once there, you web app will be able to display the rates to your users.
afache
Member
203 Points
497 Posts
Re: Determining exchange rates in .net
Sep 25, 2009 11:03 AM|LINK
Is there a free currency feed? Is it recommended to use something that is free?
Mark DotNet ...
Participant
847 Points
190 Posts
Re: Determining exchange rates in .net
Sep 30, 2009 09:53 AM|LINK
At the time of doing the project, there weren't any free feeds but that doesn't mean to say there aren't any now....although I would be surprised.
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: Determining exchange rates in .net
Sep 30, 2009 10:21 AM|LINK
You can refer here
http://www.remotemethods.com/home/valueman/converte/currency
Also here
http://www.codeproject.com/KB/cs/CurrencyConverter_Class.aspx
Contact me
Lstewart
Member
2 Points
1 Post
Re: Determining exchange rates in .net
Nov 16, 2012 02:40 PM|LINK
Public Shared Function Convert(amount As Decimal, fromCurrency As String, toCurrency As String) As Decimal Try Dim web As New WebClient() Dim url As String = String.Format("http://www.google.com/ig/calculator?hl=en&q={2}{0}%3D%3F{1}", fromCurrency.ToUpper(), toCurrency.ToUpper(), amount) Dim response As String = web.DownloadString(url) Dim regex As New Regex("rhs: ""(?<To>[0-9.\s]+)(.*?)""") Dim match As Match = regex.Match(response) Dim rate As Decimal = System.Convert.ToDecimal(regex.Replace(match.Groups(2).Value, "[^\w'\.""&:;-]+", "")) Return rate Catch generatedExceptionName As System.OverflowException Return generatedExceptionName.Message.ToString Catch generatedExceptionName As System.FormatException Return generatedExceptionName.Message.ToString Catch generatedExceptionName As System.ArgumentNullException Return generatedExceptionName.Message.ToString End Try End Function