This topic is locked

Dal Update not firing

6/28/2009 9:31:04 AM
ASPRunnerPro General questions
L
Levwinski author

Hello,
The below code is from a BeforeAdd event - the dal Update portion works fine when alone. However, when used conditionally as below it does not update the table. Nor does it give an error - it just performs the response.redirect with no impact on the database.
Any suggestions would be appreciated.

str = "select * from Accounts where CardNo='" & dict("CardNo") & "' and SimNo='" & dict("SimNo") & "'"
Set rstmp = server.CreateObject("ADODB.Recordset")
rstmp.open str,dbConnection
if not rstmp.eof then

if rstmp("Username") <> "" then

Message = "This card has already been registered."

else

dal.Accounts.Param("CardNo") = dict("CardNo")

dal.Accounts.Value("Username") = SESSION("_Customers_OwnerID")

dal.Accounts.Update

BeforeAdd = False

rstmp.close

set rstmp = nothing

response.redirect "Accounts_list.asp"

end if

else

Message = "Please enter valid card details."

end if
BeforeAdd = False

rstmp.close

set rstmp = nothing
Sergey Kornilov admin 6/30/2009

As a first step print SELECT SQL query prior to executing it and run it against your database to see if it returns any data.
Then make sure variables are populated properly by printing them on the page:

response.write dict("CardNo")

response.write SESSION("_Customers_OwnerID")

response.end