Updating e-mail address success/failure
Posted on 2006-11-14
I am writing a code where I take in a old e-mail address and then a new e-mail address and then I update the old with the new from the database. My issue I am having is that I need to print out success or failure depending on whether the old e-mail that the user inputs matches the e-mail addresses in the database. If the old e-mail address matches the database, then the update will go through and the result will be a success. But if the old e-mail address does not match the database, then the update will NOT got through and the result will be a failure.
My stored procedure is as follows:
CREATE procedure ChangeEmailAddress @oldemail varchar (75),@newemail varchar (75)
set email = @newemail
where email = @oldemail
My ASP code is as follows:
ConnectionString="Provider=SQLOLEDB;Data Source=TEST_W2K_SQL2K;Database=PhysiciansPanel;UID=paramtestuser;PWD=paramtestuser;Network Library=dbmssocn;"
Dim objconn, objRS, adocmd
Set objconn = Server.CreateObject("ADODB.Connection")
Set adocmd = Server.CreateObject("ADODB.Command")
adocmd.CommandText = "ChangeEmailAddress"
adocmd.CommandType = adCmdStoredProc
objRS = Server.CreateObject("ADODB.Recordset")
adocmd.activeConnection = objconn
adocmd.Parameters.Append adocmd.CreateParameter("@oldemail",adVarChar, adParamInput, 75)
adocmd.Parameters.Append adocmd.CreateParameter("@newemail",adVarChar, adParamInput, 75)
adocmd.Parameters("@oldemail") = Request.Form("old_email")
adocmd.Parameters("@newemail") = Request.Form("new_email")
set objRS = adocmd.Execute
if Request.Form("old_email") = objRS("email") then
I know the if-then statement is somewhat correct but I know the part with objRS("email") is definitely incorrect and I am not sure how to go upon to fixing it.
Hopefully someone will be able to help me out. I know this is probably a easy resolution that I can't come across to so any help will be appreciated. Thanks