CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: ADODB log in code.

  1. #1
    Join Date
    Dec 2010
    Posts
    5

    Question ADODB log in code.

    hey everyone im using adodb connection in login system with do until loop., but im sorry i cant understand what can this looping do in loginning account, can anyone explain it to me?
    im not the one who create this looping,., but im the one who made the connection.,.

    here the code:

    Public Sub login()
    Call dbase
    Set rspassword = New ADODB.Recordset
    rspassword.Open "Select * From Accountinfo", cnConnect, 3, 3
    If rspassword.RecordCount > 0 Then
    Do Until rspassword.EOF
    If Text1.Text = rspassword!UserName And Text2.Text = rspassword!Password Then

    Set rspassword = Nothing

    Timer1.Enabled = True
    ctr = 0
    Exit Do
    Else
    rspassword.MoveNext
    ctr = ctr + 1


    End If
    Loop
    If ctr > 0 Then
    Set rspassword = Nothing
    MsgBox "Invalid!", vbExclamation
    Text1.Text = ""
    Text2.Text = ""
    Text1.SetFocus
    ctr = 0
    End If
    End If

    End Sub

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: ADODB log in code.

    You have a counter ctr set to 0 and adding 1 each time. Then you check if it's over 0. Should only loop once.

    I don't see where you're reading in a new pw, though. Hope it's correct on the first shot?

    Take a look at this article: http://www.codeguru.com/vb/gen/vb_da...le.php/c14613/
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,345

    Re: ADODB log in code.

    The looping in the code posted is looping through every record in the password table to see if there is a match to the username and password entered.

    When it exits the loop it checks the value of ctr which will be 0 if the login was valid and if not it clears the fields and prompts the user to try again.

    btw it is hard to read wihtout code tags and proper formating of the code.
    Always use [code][/code] tags when posting code.

  4. #4
    Join Date
    Dec 2010
    Posts
    5

    Re: ADODB log in code.

    tnx poh mga sir

  5. #5
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,345

    Re: ADODB log in code.

    Quote Originally Posted by tantan05 View Post
    tnx poh mga sir
    You are welcome but please type out your words so people can read what you are saying. I understand that tnx means thanks but I have no idea what to next two things are supposed to mean. Many people here also do not do English so well so it is important to make your posts clear and not use text speak in them.
    Always use [code][/code] tags when posting code.

  6. #6
    Join Date
    Dec 2010
    Posts
    5

    Re: ADODB log in code.

    ok thanks again sir ,., im sorry

  7. #7
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: ADODB log in code.

    Please MARK THE THREAD AS RESOLVED. (First Post - Thread Tools Option)
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)