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

Submitted by: 
Visitors have accessed this post 1543 times.

In this source code you will learn on how to create a login form and connect VB.net to Microsoft Access.

Creating 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)
  7. con.Open()
  9. Dim sdr As OleDbDataReader = cmd.ExecuteReader()
  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()
  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
  5. Code for show password check box:
  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:

Tnt Number : 09096510899
Globe : 09454339345
gmail : [email protected]
Facebook : Clyde Chectopher A. Tiu

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.


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

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.