Login Form Using Visual Basic 2010 with Embbeded database Microsoft Access Tutorial

In this source code you will learn on how to create a login form and connect VB.net to Microsoft Access. Creating Database Database - First you create a database in microsoft access - copy what is on the image shown above. Step 1 Open Microsoft Visual Studio 2010 and create a new windows form application for vb. Open VBStep 2 Create your User Interface. U.IStep 3 Connect VB to MS ACCESS Step 1Step 2Step 3Step 4Step 5Step 4 Code for Log in Button
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. Dim con As New System.Data.OleDb.OleDbConnection("Provider = Microsoft.jet.OleDB.4.0;Data Source = " & Application.StartupPath & "\datastorage.mdb;")
  3. Dim cmd As OleDbCommand = New OleDbCommand( _
  4. "SELECT * FROM logininfo WHERE Username = '" & _
  5. TextBox1.Text & "' AND [Password] = '" & txtPassword.Text & "' ", con)
  6.  
  7. con.Open()
  8.  
  9. Dim sdr As OleDbDataReader = cmd.ExecuteReader()
  10.  
  11. If (sdr.Read() = True) Then
  12. MessageBox.Show("You are Now Logged In")
  13. frm1.Show()
  14. TextBox1.Focus()
  15. TextBox1.Clear()
  16. txtPassword.Clear()
  17.  
  18. Me.Hide()
  19. Else
  20. MessageBox.Show("Invalid Username or Password!")
  21. End If
  22. End Sub
Code for cancel button
  1. If MsgBox("Do you want to exit?", vbYesNo + vbQuestion) = vbYes Then
  2. Application.Exit()
  3. End If
  4.  
  5. Code for show password check box:
  6.  
  7. <vbnet>
  8. If CheckBox1.Checked = True Then
  9. txtPassword.PasswordChar =""
  10. Else
  11. txtPassword.PasswordChar = "•"
  12. End If
Hope you learn basic coding guys .... if you have questions contact me: Support Developer by donation

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Add new comment