I have an Access database that I’m trying to edit/update via VBScript via 3 different ASP files.
My problem is that although the scripts all seem to have the proper syntax, one works all of the time, one works for only some records, and one never works.
Can anyone see any obvious errors that I’m making? Tech support at the web hosting company has tried, but can’t discover any problems.
I don’t think that it’s a “rights” problem because one of the files edits the database.
updatepassword.asp allows members to change their login password. This file always works.
<%
Dim SqlStmt
Dim rst
Dim c
Set dbConn = Server.CreateObject("ADODB.Connection")
dbConn.Open Application("Members_ConnectionString")
If Session("vIDOK") = True then
SqlStmt="SELECT * FROM tMembers "
SqlStmt=SqlStmt & "WHERE LoginID = '" & Session("vID") & "' "
Set rst = Server.CreateObject("ADODB.Recordset")
rst.Open SqlStmt,dbconn,adOpenKeyset,adLockOptimistic
rst.MoveFirst
If (rst.BOF and rst.EOF) then
response.redirect "/memberloginfail.htm"
else
rst("LoginPwd")=Request.Form("NewPwd")
rst("LastChangeDate")=Date
rst("LastChangeBy")=Session("vID")
rst.Update
response.redirect "/_scripts/memberhomepage.asp"
End if
Else
response.redirect "/memberlogin.htm"
End If
rst.close
set rst = Nothing
dbConn.Close
Set dbConn = Nothing
updatemyrecord.asp allows members to change certain fields, such as phone number, address, etc. I haven’t been able to see any pattern as to why this file allows some records to be updated, but not others.
enternewmember.asp lets the membership chairperson add new members to the database. This file doesn’t generate any error messages, but new records aren’t being added.
<%
Dim SqlStmt
Dim rst
Dim fld
Dim Maxnum
Dim NewID
Dim NewPwd
Dim RandomNum
Dim CurMinute
Set dbConn = Server.CreateObject("ADODB.Connection")
dbConn.Open Application("Members_ConnectionString")
SqlStmt="SELECT Max(MemberID) AS lastid FROM tMembers"
Set rst = Server.CreateObject("ADODB.Recordset")
rst.Open SqlStmt,dbconn
Maxnum = rst("lastid").value
Maxnum = cstr(Maxnum+1)
NewID = "ABC" & Maxnum
rst.Close
set rst = Nothing
randomize
RandomNum = cstr(int(rnd * 999))
RandomNum = Right("000" & RandomNum,3)
CurMinute = minute(now)
If CurMinute