Ask a Question related to ASP Database, Design and Development.
-
Patrick #1
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
-
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... -
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.... -
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... -
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... -
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... -
Bob Barrows #2
Re: Problem updating to database
Patrick wrote:
Not unless you tell us what "doesn't run" means. Error messages? Wrong>
> 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?
>
results? What?
Bob Barrows
Bob Barrows Guest
-
Bullschmidt #3
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



Reply With Quote

