[thelist] Currency Conversion (ASP) - pls help !

Fred Schenk Evolt at FredSchenk.com
Sat Feb 1 16:06:00 CST 2003


If you want to enter the amounts in multiple currencies and have them
convert to a standard currency this will do:

Table tProduct:
Price <money>
Currency <char(3)>

Table tCurrency
Currency <char(3)>
ExchangeRate <numeric (5,5)>
LastUpdate <datetime>

Just leave the prices as they are and calculte the displayed amount on the
fly. Don't forget to mention that the prices are just an indication.

SELECT
    tProduct.Name
,    ISNULL(tCurrency.Currency, tProduct.Currency)
,    tProcuct.Prize * ISNULL(tCurrency.ExchangeRate,1) AS CalculatedPrice
,    tCurrency.LastUpdate
FROM tProduct
LEFT JOIN tCurrency
    ON tProduct.Currency = tCurrency.Currency

If the LastUpdate equals NULL then the exchange rate isn't in the database.
You'll always be able to show a price, since you'll have a corresponding
currency.

If you want to give the user a choice you'll have to add a division to the
calculation with the ExchangeRate of the currency the user has chosen (don't
forget the ISNULL) and select the least of the two LastUpdate dates.

For the feed of the exchange rates you should contact some suppliers, since
it won't be handed out freely. You could always 'steal' it from some
internet pages which works as long as they don't change their format, but
that wouldn't be the professional thing to do.

Gtx,
     Fred

----- Original Message -----
From: "Waldi Krogmann" <webmaster at humor.co.za>
Sent: 01 February 2003 8:27 PM

> - I am looking for ways to add a currency converter to my ASP site (Access
DB)
> - Just to convert from US dollar ($) to South African Rand (R), - no other
> currencies. This values will be added in a "shopping basket"
>
> (I don't want a link / converter on my site, everything will be in the DB
> / back-end, so that the users don't have to do the conversion
themselves...)
>
> The idea is to add the current exchange rate (manually through an admin
> page) to the Access database , then all the product prices (in DB) should
> automaticaly be adjusted.
> e.g. the Product price displayed on the web will be in Rand, not $ ...
>
> Perhaps there is a way to the add the exchange rate automatically everyday
> from the web (import), from a bank or currency site (but if they change
> their url / fields it might cause  problems). Then the admin page won't be
> necessary ...i
>
> Anyone know how to do this ?
>
> Thank You !




More information about the thelist mailing list