user1212515
user1212515

Reputation: 1

Update Only one field in MS SQL Using Classic ASP

I have been banging my head with this script and need to assistance. I am trying to create a registration form that connects to the following sql fields: Acct_ID, Username, Password, FirstName, LastName, Confirmation, RegistrationDate and AccountNum.

What I have been able to do so far is get the form inserted into the database and have a cdosys email sent out to the email address(username) with a querystring attached to a link embedded in the email. The querystring is the AccountNum field from the registration form.

What I want to try to do is update the confirmation field only in the database when the user clicks on the link which looks like this: http://www.domainname.com/Presenter_Account_Confirm_Registration.asp?AccountNum=2152012319101300766363428210152260.

I verified that the Account Number is transferred to the confirmation page, but I am stumped as to how to update just the confirmation field in the database. Any help would be greatly appreciated. Thank you!

Upvotes: 0

Views: 1037

Answers (1)

Aaron Bertrand
Aaron Bertrand

Reputation: 280330

Making some assumptions here, that Acct_ID is an INT, is the same as AccountNum, and that you want to set Confirmation to 1:

<%
  Acct_ID = Request.QueryString("AccountNum")
  set cmd = CreateObject("ADODB.Command")
  cmd.ActiveConnection = conn ' assume ADODB.Connection has been set up
  cmd.CommandType = adCmdText
  sql = "UPDATE dbo.tablename SET Confirmation = 1 WHERE Acct_ID = ?"
  cmd.Parameters(0).value = Acct_ID
  cmd.CommandText = sql
  cmd.Execute
%>

Upvotes: 2

Related Questions