Problem updating to database

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Problem updating to database

    <%
    dim ORIG
    dim MSG
    dim KEYWORD
    strNum = request.QueryString("ORIG") ''get mobile number from VisualGSM
    strKey = lcase(request.QueryString("KEYWORD")) ''gets Keyword from VisualGSM
    strLongMsg = lcase(request.QueryString("MSG")) ''gets SMS message from VisualGSM
    strLongMsg = replace(strLongMsg, "<", "")
    strLongMsg = replace(strLongMsg, ">", "")
    strLongMsg = replace(strLongMsg, "(", "")
    strLongMsg = replace(strLongMsg, ")", "")
    strLongMsg = replace(strLongMsg, "''", "")
    strLongMsg = replace(strLongMsg, ",", "")

    DBPath = server.MapPath("../../db/trivia.mdb")
    ''Path to Database
    strDb = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="& DBPath
    set connTrivia = Server.CreateObject("ADODB.Connection")
    connTrivia.Open strDB

    strStart = "trivia"
    strAKey = "a"

    strKey = "trivia"
    strNum = "+60123598311"
    strLongMsg = lcase("lion king")

    ''Recordset to check if the user exists
    set rsCheckUser = Server.CreateObject("ADODB.recordset")
    SQLStr1 = "SELECT * FROM tblUserInfo WHERE msisdn = ''" & strNum & "''"
    rsCheckUser.Open SQLStr1, ConnTrivia, 3, 3, cmdText

    ''Recordset to Add a new user
    set rsAddUser = Server.CreateObject("ADODB.recordset")
    SQLStr1 = "SELECT * FROM tblUserInfo"
    rsAddUser.Open SQLStr1, ConnTrivia, 3, 3, cmdText

    ''Recordset for Question and Answer
    set rsQNum = Server.CreateObject("ADODB.recordset")
    SQLStr2 = "SELECT * FROM tblTrivia"
    rsQNum.Open SQLStr2, ConnTrivia, 3
    rsQNum.movefirst
    strQNum = rsQNum.recordcount

    if strKey = strStart then
    ''checking to see if the User is new
    If rsCheckUser.RecordCount = 1 Then
    strNewUser = "NO"
    Else
    strNewUser = "YES"
    End If
    if strNewUser = "YES" then
    ''adding new user
    ''rsAddUser.AddNew
    ''rsAddUser("msisdn") = strNum
    ''rsAddUser("nick") = strNick
    ''rsAddUser("lvl") = 1
    ''rsAddUser("senttimestamp") = now()
    ''rsAddUser.Update
    ''rsAddUser.Requery
    strSQL2 = "INSERT INTO tblUserInfo (msisdn, nick, lvl, senttimestamp) values(''"& strNum & "'',''" &strNick& "'',''1'',''"& now() &"'')"
    set rsNewUser = connTrivia.execute(strSQL2)
    response.write("1) " & rsQNum("question"))
    elseif strNewUser = "NO" then
    ''checks what level is the user at and then sends the question to them
    strLvl = int(rsCheckUser("lvl"))
    set rsCheckQ = Server.CreateObject("ADODB.recordset")
    SQLStr2 = "SELECT * FROM tblTrivia WHERE lvl = " & strLvl
    rsCheckQ.Open SQLStr2, ConnTrivia, 3
    response.write(strLvl & ") " & rsCheckQ("question"))
    end if
    ''checks to see if the answer is correct
    elseif strKey = strAKey then
    If rsCheckUser.RecordCount = 1 Then
    strLvl = int(rsCheckUser("lvl"))
    set rsCheckQ = Server.CreateObject("ADODB.recordset")
    SQLStr2 = "SELECT * FROM tblTrivia WHERE lvl = " & strLvl
    rsCheckQ.Open SQLStr2, ConnTrivia, 3
    strAnswer = Lcase(rsCheckQ("answer"))
    strAltAnswer = Lcase(rsCheckQ("altAnswer"))
    if strLongMsg = strAnswer OR strLongMsg = strAltAnswer then
    if int(strQNum) > int(strLvl) then
    strLvl = strLvl + 1
    dSentTimeStamp = (rsCheckUser("senttimestamp"))
    dReceivedTimeStamp = now()
    strSec = DateDiff("s",dSentTimeStamp,dReceivedTimeStamp)
    strElapsedTime = strSec & "s"
    '' Now updating records
    rsCheckUser("lvl") = strLvl
    rsCheckUser("receivedtimestamp") = dReceivedTimeStamp
    rsCheckUser("elapsedtime") = strElapsedTime
    rsCheckUser.Update
    rsCheckUser.Requery
    set rsNextQ = Server.CreateObject("ADODB.recordset")
    SQLStr2 = "SELECT * FROM tblTrivia WHERE lvl = " & strLvl
    rsNextQ.Open SQLStr2, ConnTrivia, 3
    if not rsNextQ.EOF then
    response.write(strLvl & ") " & rsNextQ("question"))
    else
    response.write("Thank You for playing, you have completed the trivia!")
    end if
    else
    response.write("Thank You for playing, you have completed the trivia!")
    end if
    else
    response.write("Sorry Wrong Answer, Please Try Again.")
    end if
    else
    response.write("If this is your first time please type in TRVIA instead.")
    end if
    else
    response.write("Key is Wrong, Please key in TRIVIA to start or A to answer.")
    end if
    %>

    The above is the code whereby I am trouble updating the database. It runs perfectly on the localhost but then when i upload it to the webserver it doesn''t run. Anyone have any ideas on how to resolve this problem?
    Thank you!

    -----------------------------
    This message is posted by [url]http://Asp.ForumsZone.com[/url]

    Patrick Guest

  2. Similar Questions and Discussions

    1. updating a database.
      at the moment is am trying to create a page to update a database. i select the a company in a list which the gets forwarded to the next page. On...
    2. updating database
      I posted this in the general dis part too but maybe this is better place since it has to do with forms... here is my problem I need to overcome....
    3. Updating a Database
      Hi I am just learning asp.net and have hit a wall with the datagrid control. I have populated a datagrid and am able to edit fields and retrieve...
    4. Updating database information
      I am trying to collect information from a form on one page and then pass it to the page with the code below for processing. I can get the data to...
    5. Updating Database with ASP
      Hi, I'm just learning how to use ASP and I've been trying to figure out how to add records to my database. I'm learning it out of a book and...
  3. #2

    Default Re: Problem updating to database

    Patrick wrote:
    >
    > The above is the code whereby I am trouble updating the database. It
    > runs perfectly on the localhost but then when i upload it to the
    > webserver it doesn''t run. Anyone have any ideas on how to resolve
    > this problem?
    >
    Not unless you tell us what "doesn't run" means. Error messages? Wrong
    results? What?

    Bob Barrows


    Bob Barrows Guest

  4. #3

    Default Re: Problem updating to database

    Without knowing anything more like error messages, perhaps this line
    needs to be tweaked:

    DBPath = server.MapPath("../../db/trivia.mdb")

    Best regards,
    J. Paul Schmidt, Freelance ASP Web Developer
    [url]http://www.Bullschmidt.com[/url]
    ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Bullschmidt Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139