LoginForm that accepts multiple users and passwords

Posted on 2009-12-16
Last Modified: 2012-05-08
I made a login form using the code from a related solution "how to make a login form for an application".

My next question is how to set up the text files to hold the actual user names and passwords that I will add to allow the users access to my application.

Question by:Danean
    LVL 9

    Accepted Solution

    You can save that information either in database or in XML file
    if you are having user creation module in your application then you can fill dataset from XML file
    add new users to that dataset then
    Finally save the dataset as xml like


    Author Comment

    I am using a LoginForm and I can hardcode in each user with what I have below.  I am not sure how to code it to compare what the user input to see if it is in the file.

    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
            If UsernameTextBox.Text = "user" And PasswordTextBox.Text = "password" Or UsernameTextBox.Text = "user" And PasswordTextBox.Text = "password" Then
            End If

        End Sub

    Author Comment

    I came up with an answer which works great.  Thanks for your help.

    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
            Dim cn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=(path\file.mdb;" + "User id=admin;" + "Password=")
            Dim cmd As OleDbCommand = New OleDbCommand("select count(*) from User1 where username='" + Me.UsernameTextBox.Text + "'and password='" + Me.PasswordTextBox.Text + "'", cn)
            Dim count As Integer = Convert.ToInt32(cmd.ExecuteScalar())
            If (count > 0) Then
                MsgBox("Login Failed")
            End If
        End Sub


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now