ASP Script not working...need second pair of eyes

Discussion in 'C#' started by dean_z, Jan 15, 2008.

  1. #1
    I have been working on generating ASP scripting to drop form data into an access database. What I have it currently set to do is drop the form data into an email as well as drop it into an access database on the server. The code is as follows. So far, it drops into the email but I can not figure out where it is hanging after that.... any help would be a godsent!


    ' A Function to check if some field entered by user is empty

    Function ChkString(string)

    If string = "" Then string = " "

    ChkString = Replace(string, "'", "''")

    End Function



    ' Receiving values from Form





    HDID = ChkString(Request.Form("HDID"))
    SSSID = ChkString(Request.Form("SSSID"))
    order = ChkString(Request.Form("order"))
    site = ChkString(Request.Form("site"))
    brand = ChkString(Request.Form("brand"))
    app = ChkString(Request.Form("app"))
    calltype = ChkString(Request.Form("calltype"))
    keyword = ChkString(Request.Form("keyword"))
    promo = ChkString(Request.Form("promo"))
    product = ChkString(Request.Form("product"))
    question = ChkString(Request.Form("question"))





    data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _

    Server.MapPath("\fpdb\hdlog2.mdb")



    sql_insert = "insert into results (HDID, SSSID, order, site, brand, app, calltype, keyword, promo, product, question)values ('" & HDID & "','" & SSSID & "','" & order & "','" & site & "','" & brand & "','" & app & "','" & calltype & "','" & keyword & "','" & promo & "','" & product & "','" & question & "')"


    'Creating Connection Object and opening the database

    Set con = Server.CreateObject("ADODB.Connection")

    con.Open data_source

    con.Execute sql_insert



    'Done. Close the connection

    con.Close

    Set con = Nothing


    Response.Redirect "thanks.htm"

    %>


    regards,
    Dean
     
    dean_z, Jan 15, 2008 IP
  2. webexpert

    webexpert Banned

    Messages:
    188
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    first of all.. try to debug it.. like before this line;

    Server.MapPath("\fpdb\hdlog2.mdb")

    write this;

    response.write(Server.MapPath("\fpdb\hdlog2.mdb"))
    response.end

    and see if your db path is correct... if this is correct, then next problem can be this;

    are you sure that the below fields are text fields;

    HDID, SSSID

    if they are numeric fields then please remove the apostrophy ( ' ) from their values...

    instead of '" & HDID & "', try " & HDID & "

    hope this will help you..

    regards,
     
    webexpert, Jan 16, 2008 IP