To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
MSDN Subscribers: Download the VS 2010 Release Candidate
MSDN Subscribers: Download the VS 2010 Release Candidate
Sell Your Code and Make Money?
Creating your own Tetris game using VB.NET
Article :: Improving Software Economics, Part 4 of 7: Top 10 Principles of Iterative Software Management



Go Back   VBForums > Visual Basic > Database Development

Reply Post New Thread
 
Thread Tools Search this Thread Display Modes
Old Apr 5th, 2007, 12:19 PM   #1
matrik02
Frenzied Member
 
matrik02's Avatar
 
Join Date: Feb 07
Location: Malaysia
Posts: 1,349
matrik02 is an unknown quantity at this point (<10)
Resolved [RESOLVED] password problem

I have a problem.Actually I want to set a counter that allow the user to enter the valid password for 3 times.. if the password fail after 3 times attempt, the form 1 show.How to do that?


Code:
Set adoConn = New ADODB.Connection
    Set adoRS = New ADODB.Recordset

    Dim cs As String
        cs = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\AdminPassword.mdb" & ";Persist Security Info=False;"

    adoConn.ConnectionString = cs
    adoConn.Open

If Text2.Text = "" Then

        MsgBox "Sila masukkan Kata laluan Anda", vbCritical, "Kata laluan"
      '  MsgBox "Sila masukkan Kata laluan Anda"
        Text2.Text = ""
        Text2.SetFocus
    Else
    
     usrnm = Text2.Text
     adoRS.Open "SELECT * FROM pass WHERE password='" & usrnm & "';", adoConn, adOpenStatic, adLockOptimistic
        
   
        
     If adoRS.Fields("Password").Value = Text2.Text Then
        pass = True
        'if password valid, success
        MsgBox "Anda Berjaya memasuki ruang admin" & vbCrLf & "Logged in. Username: " & usrnm & " !", vbInformation, "Selamat datang"
        Form2.Show
        Unload Me
    Else
    'if password invalid,message box ask to insert invalid password
         MsgBox "Kata laluang tidah sah. Ruang ini hanya untuk admin", vbCritical, "WARNING"
         'Exit Sub
         Unload Me
         Form1.Show
    

        Exit Sub
    End If
 End If
End Sub
matrik02 is offline   Reply With Quote
Old Apr 5th, 2007, 12:44 PM   #2
Hack
Super Moderator
 
Hack's Avatar
 
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 52,309
Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)
Re: password problem

Something like
vb Code:
  1. Dim intCounter As Integer
  2. Set adoConn = New ADODB.Connection
  3.     Set adoRS = New ADODB.Recordset
  4.     Dim cs As String
  5.         cs = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\AdminPassword.mdb" & ";Persist Security Info=False;"
  6.     adoConn.ConnectionString = cs
  7.     adoConn.Open
  8. If Text2.Text = "" Then
  9.         MsgBox "Sila masukkan Kata laluan Anda", vbCritical, "Kata laluan"
  10.       '  MsgBox "Sila masukkan Kata laluan Anda"
  11.         Text2.Text = ""
  12.         Text2.SetFocus
  13.     Else
  14.    
  15.      usrnm = Text2.Text
  16.      adoRS.Open "SELECT password FROM pass WHERE password='" & usrnm & "';", adoConn, adOpenStatic
  17.      If adoRS.Fields("Password").Value = Text2.Text Then
  18.         pass = True
  19.         'if password valid, success
  20.         MsgBox "Anda Berjaya memasuki ruang admin" & vbCrLf & "Logged in. Username: " & usrnm & " !", vbInformation, "Selamat datang"
  21.         Form2.Show
  22.      Else
  23.         intCounter = intCounter + 1
  24.            If intCounter = 3 Then
  25.               Form1.Show
  26.            Else
  27.               Msgbox "Invalid Password"
  28.            End If
  29.      End If
__________________
Please use [Code]your code goes in here[/Code] tags when posting code.
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum.

Creating A Wizard In VB.NET
Modifications Required For VB6 Apps To Work On Vista
Paging A Recordset
What is wrong with using On Error Resume Next
IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects!
Microsoft MVP 2005/2006/2007/2008/2009
Hack is online now   Reply With Quote
Old Apr 5th, 2007, 01:08 PM   #3
matrik02
Frenzied Member
 
matrik02's Avatar
 
Join Date: Feb 07
Location: Malaysia
Posts: 1,349
matrik02 is an unknown quantity at this point (<10)
Re: password problem

The counter value did not change. The value does not increase. It still start with 0 value.

Code:
If adoRS.Fields("Password").Value = Text2.Text Then
        pass = True
        'if password valid, success
        MsgBox "Anda Berjaya memasuki ruang admin" & vbCrLf & "Logged in. Username: " & usrnm & " !", vbInformation, "Selamat datang"
        frmmanagement.Show
        Unload Me
        
      Else
         intCounter = intCounter + 1
         
         If intCounter = 3 Then
         frmMenu.Show
         Unload Me
         Else
        'if password invalid,message box ask to insert invalid password
         MsgBox "Invalid password", vbCritical, "WARNING"
         Text2.Text = ""
         Text2.SetFocus
         End If
    End If
matrik02 is offline   Reply With Quote
Old Apr 5th, 2007, 01:15 PM   #4
Hack
Super Moderator
 
Hack's Avatar
 
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 52,309
Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)
Re: password problem

If the first part of your code works (which I did not test) that would tell me the password was valid.
__________________
Please use [Code]your code goes in here[/Code] tags when posting code.
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum.

Creating A Wizard In VB.NET
Modifications Required For VB6 Apps To Work On Vista
Paging A Recordset
What is wrong with using On Error Resume Next
IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects!
Microsoft MVP 2005/2006/2007/2008/2009
Hack is online now   Reply With Quote
Old Apr 5th, 2007, 01:21 PM   #5
matrik02
Frenzied Member
 
matrik02's Avatar
 
Join Date: Feb 07
Location: Malaysia
Posts: 1,349
matrik02 is an unknown quantity at this point (<10)
Re: password problem

Yes. But if the password invalid, it go to the second part. at the second part, the user are allow enter the password for 3 times.After 3 attempt,If the password invalid the frmMenu will appear

Code:
intCounter = intCounter + 1
         
         If intCounter = 3 Then
         frmMenu.Show
         Unload Me
         Else
        'if password invalid,message box ask to insert invalid password
         MsgBox "Invalid password", vbCritical, "WARNING"
         Text2.Text = ""
         Text2.SetFocus
         End If
matrik02 is offline   Reply With Quote
Old Apr 5th, 2007, 01:31 PM   #6
Hack
Super Moderator
 
Hack's Avatar
 
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 52,309
Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)
Re: password problem

If you are doing this all in a button click, then you are resetting the counter each time you click it. Take Dim intCounter As Integer and move it the forms declaration section and declare it as Private.
__________________
Please use [Code]your code goes in here[/Code] tags when posting code.
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum.

Creating A Wizard In VB.NET
Modifications Required For VB6 Apps To Work On Vista
Paging A Recordset
What is wrong with using On Error Resume Next
IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects!
Microsoft MVP 2005/2006/2007/2008/2009

Last edited by Hack; Apr 5th, 2007 at 02:08 PM.
Hack is online now   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Database Development


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:56 AM.




To view more projects, click here

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.