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
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Visual Basic > Database Development

Reply Post New Thread
 
Thread Tools Display Modes
Old Apr 5th, 2007, 11:19 AM   #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, 11:44 AM   #2
Hack
Super Moderator
 
Hack's Avatar
 
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 54,243
Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)
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
Good Article: Language Enhancements In Visual Basic 2010
IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects!
Upgrading VB6 Code To VB.NET
Microsoft MVP 2005/2006/2007/2008/2009/2010
Hack is offline   Reply With Quote
Old Apr 5th, 2007, 12: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, 12:15 PM   #4
Hack
Super Moderator
 
Hack's Avatar
 
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 54,243
Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)
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
Good Article: Language Enhancements In Visual Basic 2010
IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects!
Upgrading VB6 Code To VB.NET
Microsoft MVP 2005/2006/2007/2008/2009/2010
Hack is offline   Reply With Quote
Old Apr 5th, 2007, 12: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, 12:31 PM   #6
Hack
Super Moderator
 
Hack's Avatar
 
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 54,243
Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)
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
Good Article: Language Enhancements In Visual Basic 2010
IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects!
Upgrading VB6 Code To VB.NET
Microsoft MVP 2005/2006/2007/2008/2009/2010

Last edited by Hack; Apr 5th, 2007 at 01:08 PM.
Hack is offline   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
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 05:24 AM.





Acceptable Use Policy

Internet.com
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.