Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Convert web site from Access Database to SQL

$
0
0

We have used an Access Database on our web site for some time, but it has been suggested that we update to SQL for any future upgrades.

The script that access the database looks like:-

<%
    Response.Buffer = True
    Dim intState, intAge, txtSmoker, txtGender, curPremium
    
    if isEmpty(Request.Form("selectstate"))then
        intState = Alabama
    else
        intState = Request.form("selectstate")
    end if
    
    if IsEmpty(Request.Form("selectage")) then
        intAge = 20
    else
        intAge = Request.Form("selectage")
    end if
    
    if IsEmpty(Request.Form("Smoker")) then
        txtSmoker = "No"
    else
        txtSmoker = Request.Form("Smoker")
    end if

    if IsEmpty(Request.Form("Gender")) then
        txtGender = "Male"
    else
        txtGender = Request.Form("Gender")
    end if
    
    dim MinPremium, MaxPremium
    MinPremium = 10000 '    minimum monthly premium
    MaxPremium = 250000
    commission = 0 ' percent
    if IsEmpty(Request.Form("SelectPremium")) then
        curPremium = MinPremium
    else
        curPremium = CCur(Request.Form("SelectPremium"))
    end if
    dim adoConn, rsCost
    set adoConn = CreateObject("ADODB.Connection")
    set rsAges = CreateObject("ADODB.Recordset")
    set rsCost = CreateObject("ADODB.Recordset")

    filePath = Server.MapPath("db/costs101.mdb")
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & filePath
    adoConn.Open strConn
    
    intEffectiveAge = intAge
    if txtGender = "Female" then
        intEffectiveAge = intEffectiveAge - 3
        if intEffectiveAge < 20 then intEffectiveAge = 20
    end if
    if txtSmoker = "No" then
        txtCostField = "[Non Smoker Cost]"
    else
        txtCostField = "[Smoker Cost]"
    end if
    strSQL = "SELECT " & txtCostField & " as Cost FROM Costs WHERE ([AGE NEXT] = " & intEffectiveAge & ")"
    rsCost.Open strSQL, adoConn
    adjustmentFactor = (100 - commission)/100.0
    if not rsCost.BOF then
        rate = rsCost("Cost")
        lifeAss = curPremium/1000 * rate * 1.90
        lifeAss = int(100*lifeAss)/100
        lifeAss = FormatNumber(lifeAss,2)
    else
        Response.Write "Could not find cost for age " & intAge
    end if
    rsCost.Close
%>

What do we need to do to migrate to an SQL database.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>