locked
login form from an access database in vb 2010

    Question

  • hi i am working on a project that involves checking that a persons login and password are that of held in the database
    each person has a seperate username and password i seem to have stumbled across an error. here is the code and i will underline the problems any help will be of great use to me thanks 

            Dim lookupusername As project_dbDataSet.Login_DetailsRow
            Dim lookuppassword As project_dbDataSet.Login_DetailsRow
            Dim match As Integer

            lookuppassword = txtPassword.Text
            lookupusername = txtusername.Text
            lookupusername = Project_dbDataSet.Login_Details![Login_ID]
            lookuppassword = Project_dbDataSet.Login_Details![password]
            match = False
            If (username = lookupusername) And (password = lookuppassword) Then
                match = True
                frmHome.Show()
            End If
            Do While match <> True
                If match = False Then
                    For I = 0 To Project_dbDataSet.Login_Details.Count - 1
                        lookupusername = Project_dbDataSet.Login_Details![Login_ID]
                        lookuppassword = Project_dbDataSet.Login_Details![password]
                        If (username = lookupusername) And (password = lookuppassword) Then
                            match = True
                            frmHome.Show()
                        Else
                            MsgBox("access denied your username or password is incorrect please try again")
                            match = False
                            txtusername.Text = " "
                            txtPassword.Text = " "
                            txtusername.Focus()
                        End If
                    Next
                End If
            Loop
        End Sub
    thanks again 
    • Moved by YiChun Chen Monday, March 01, 2010 8:28 AM VB issue (From:.NET Framework Setup)
    Thursday, February 25, 2010 9:21 PM

All replies

  • Hi Imploding lama,

    I am moving this thread from Base ".Net Framework Setup" forum to the "Visual Basic Language" forum, since the issue is related to VB. There are more experts in the "Visual Basic Language" forum.

    Thanks
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, March 01, 2010 8:27 AM
  • Thank you YiChun for your friendly help and support.

    Hi imploding,

    Welcome to MSDN forums!

    1. There are two mistakes in your code.

        1) Please change:

            lookuppassword = txtPassword.Text
            lookupusername = txtusername.Text

            to:
            password = txtPassword.Text
            username = txtusername.Text


        2) The Do While Loop statement is redundant.
             Do While match <> True
                ...
             Loop


    2. Here is FAQ with code sample for you to check: How do I create a Login Verification routine (Login Form) in VB.NET
    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/b2eaa4a2-a202-4cad-9673-75a0d35d79fe


    Best regards,
    Martin Xie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, March 02, 2010 5:35 AM
    Moderator
  • There is still an error code in the same places the blue underline is always there.

    i have tried declaring it but it wont let me declare it as anysort of integer string character or anything it will always underline it and say
    cannot be converted to
    string or integer which ever you declare it as  

    thanks

    Tuesday, March 02, 2010 9:21 AM
  • Please check the following modified code:

         Dim lookupusername As String
         Dim lookuppassword As String
         Dim match As Boolean
         Dim username As String
         Dim password As String

            password = txtPassword.Text
            username = txtusername.Text

            lookupusername = Project_dbDataSet.Login_Details![Login_ID].ToString
            lookuppassword = Project_dbDataSet.Login_Details![password].ToString


    Please check this FAQ with code sample: How do I create a Login Verification routine (Login Form) in VB.NET. It works fine.
    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/b2eaa4a2-a202-4cad-9673-75a0d35d79fe


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, March 03, 2010 6:11 AM
    Moderator
  • Why are you using a login form in 2010 as normally the user has already loged on to his computer.

    A login form has commonly only sense in an ASPNet application.

    Environment.Username

    http://msdn.microsoft.com/en-us/library/system.environment.username.aspx
    Success
    Cor
    Wednesday, March 03, 2010 6:17 AM
  • im creating a program to login to a system using vb 2010  and i cant get the code right :/  that was no help :/

    i will try ure solution martin many thanks
    Friday, March 05, 2010 9:19 AM
  • Hi imploding,

    If you leave your email here, I will send my sample project to you  for checking.
    v-maxie@microsoft.com

    Best regards,
    Martin Xie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, March 08, 2010 5:21 AM
    Moderator
  • hi the code works but its now trying to convert the string files to integer ansd nothing is set as an integer
    Thursday, March 11, 2010 3:02 PM