Help! Simple code problem with database connection

Results 1 to 3 of 3

Thread: Help! Simple code problem with database connection

  1. #1
    Join Date
    Dec 1969

    Default Help! Simple code problem with database connection

    Hello, I know this is easy to you so I figured why not ask as I tinker with it... <BR><BR>I have a script that connects to database and uses one time passwords...with the help of the good people here.<BR><BR>Question is how do I format it to make NEVER EXPIRING passwords? In other words, let the password be used over and over the code:<BR><BR>&#060;%<BR>&#039 This page will check the database for the<BR>&#039 correct password and see if that password<BR>&#039 has already been used.<BR>Dim db<BR>Dim rst<BR>Dim result<BR>Dim pwd<BR>Dim blnValid<BR>pwd = Request.Form("Password")<BR>&#039 If the form hasn&#039t been submitted then bypass this<BR>If pwd &#060;&#062; "" Then &#039 a password has been passed<BR>&#039 Connect to the database<BR>Set Myconn = Server.CreateObject("ADODB.Connection")<BR>conStri ng = "DBQ=" & Server.MapPath("cbs.mdb")<BR>Myconn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & conString<BR>&#039 Create a recordset object and load all of the records from the database.<BR>Set rst = Server.CreateObject("ADODB.Recordset")<BR> "Select * From passwords WHERE HasTaken=False AND password=&#039" & pwd & "&#039", Myconn, 3, 3<BR>If rst.BOF And rst.EOF Then<BR>&#039 password invalid (does not exist or has been used)<BR>blnValid = False<BR>Else<BR>&#039 valid password<BR>blnValid = True<BR>rst("HasTaken") = True &#039 switch off this password<BR>rst.Update<BR>End If<BR>rst.close<BR>Myconn.close<BR>Set rst = Nothing<BR>Set Myconn = Nothing<BR>Else &#039 no password passed from form<BR>blnValid = False<BR>End If<BR><BR>If blnValid Then &#039 password was valid<BR>Response.Redirect "formtest.asp"<BR>Else &#039 password was not (not found, already used, or empty string passed)<BR>Response.Redirect "rejected.asp"<BR>End If<BR>%&#062;<BR><BR><BR>Thanks a lot...I appreciate your time.

  2. #2
    Somnath Dhar Guest

    Default RE: Help! Simple code problem with database connec

    Get rid of these two lines<BR><BR>&#039rst("HasTaken") = True &#039 switch off this password<BR>&#039rst.Update<BR>

  3. #3
    Join Date
    Dec 1969

    Default Still won't work...thanks...hmmm...

    I tried it and got an error. I set my passwords to &#039true&#039 and those lines of code you suggest to take out in turn would update them to false so they would never work again.<BR><BR>I took them out but it gave an error...a type mismatch...<BR><BR>Do I need to remove the boolean &#039true&#039 values from the passwords and just leave them alone IN ADDITION to what you told me?<BR><BR>I must be missing something...I just want a database connection where they submit a password and enter a page. That password NEVER expires...I must be overlooking something...<BR><BR>What would you suggest? Thanks.<BR><BR>Joel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts