Saturday, February 10, 2018

Login Security System with Display Username in Visual Basic NET and Microsoft Access

Here is a program that I wrote using Microsoft Visual Basic NET 2013 and Microsoft Access 2010 to protect the user from intruders I called this program login security system. The program will search and display the name of the registered user of the system. I hope you will find my work useful.

I am currently accepting programming and web development work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.




Database, Table and Sample Record structure in Microsoft Access 2010









Sample Program Output


Program Listing

Form1.vb

Imports System.Data.OleDb


Public Class Form1
    Public fullname As String
    Dim user As String = ""
    Dim pass As String = ""

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\Login.accdb")
        Dim cmd As OleDbCommand = New OleDbCommand( _
                   "SELECT * FROM tblusers WHERE USERNAME = '" & _
                   TextBox1.Text & "' AND PASSCODE = '" & TextBox2.Text & "' ", con)
        con.Open()
        Dim sdr As OleDbDataReader = cmd.ExecuteReader()
        If (sdr.Read() = True) Then
            user = sdr("USERNAME")
            pass = sdr("PASSCODE")
            fullname = sdr("FIRSTNAME") + " " + sdr("LASTNAME")
            Form2.Show()
        Else
            MessageBox.Show("Invalid username or password!")
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox1.Focus()
        End If
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
End Class

Form2.vb

Public Class Form2

    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Show()
        Label2.Text = Trim(Form1.fullname)
    End Sub
End Class







No comments:

Post a Comment