我一直试图让一些ASP代码工作一段时间而根本不能(我是一个PHP人并且与某人签约为我这样做,但他现在拒绝回复电子邮件)。所以我想知道是否有人可以帮助我解决我遇到的问题并解释这个代码的问题。这是代码:
'------------ Connect to MySQL --------------------------
sConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=" & sServer & "; DATABASE=" & sDBName &"; UID=" & sDBUser & ";PASSWORD=" & sDBPass & "; PORT=3306;"
Set oConnection = Server.CreateObject("ADODB.Connection")
oConnection.Open(sConnection)
Set oRS = Server.CreateObject("ADODB.Recordset")
'------------ Connect to MySQL --------------------------
'Checks if the cookie exists
sCookieValue = Request.Cookies(sCookieName)
bCookieFound = CBool(Len(sCookieValue) > 0)
if bCookieFound then
oRS = oConnection.Execute("SELECT * FROM sessions WHERE id=" & sCookieValue )
Dim bSDFound
Dim sDate
bSDFound = false
Do while NOT oRS.EOF
bSDFound = true
sDate = oRS("date")
oRS.MoveNext ' Next record
Loop
' Check if found in the DB
if bSDFound then
'Convert from universal Date format
Dim dateDB
dateDB = CDate(Mid(sDate, 1, 10) & " " & Mid(sDate, 12, 8))
'Check if is longer than 1 hour old
if DateDiff("n", dateDB, Now) > 60 then
Response.Redirect urlLogin
else
'If it is not older than an hour, update it to the current timestamp and redirect
oConnection.Execute("UPDATE sessions set date=Now() WHERE id=" & sCookieValue )
Response.Redirect urlWelcome
end if
else
Response.Redirect urlLogin
end if
else
Response.Redirect urlLogin
end if
我很确定这个问题出现在“while NOT循环”的某个地方,但我对ASP的了解并不充分。
我知道: - 正在使用的MySQL信息是正确的, - 删除while循环时代码有效。
真正感谢任何帮助。
答案 0 :(得分:0)
oRS = oConnection.Execute(应设置oRS = oConnection.Execute( - Gaby aka G. Petrioli