ARTICLE

How to create the login form in VB.NET

Posted by Munesh Sharma Articles | ADO.NET in VB.NET April 26, 2011
In this article, we will learn about the Login form in VB.NET.
Download Files:
 
Reader Level:

Login form:

Login form is a way by which you can easily identify the users of an application. there are various steps to create the login form, that are:

  • Step first, to Design the window forms:

    logindegin.gif

    signup.gif

  • Step second, to Design the Data Base:

    data-base-design.gif

  • Step third, establish connection B/w application and database
    Imports System.Data.OleDb
    Module
    Module1
        Public constringAs OleDbConnection =New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=D:\My_db11.accdb")

    End
    Module

  • Step four, write Sign in code:
    Imports System.Data.OleDb
    Imports
    System.Windows.Forms  
    Public
    Class Form1
        Dim Str As String
        Dim Ds As DataSet
        Dim Da As OleDbDataAdapter 
        Private Sub Button2_Click(ByVal senderAs System.Object, ByVal e As System.EventArgs)Handles Button2.Click
            Dim Signup As New Signup
            Signup.Show()  
        End Sub
     
        Private Sub Button1_Click(ByVal senderAs System.Object, ByVal e As System.EventArgs)Handles Button1.Click
            constring.Open()         Str = "Select Fname,Password from info2 where Fname='" & TextBox1.Text &"' and  Password ='" & TextBox2.Text &"';"
     
            Dim com As New OleDbCommand(Str, constring)
            Dim rd As OleDbDataReader = com.ExecuteReader() 
            If rd.Read() =True Then
     
                MessageBox.Show("Valid username and password"
            Else
     
                MessageBox.Show("Invalid username and password"
            End If
     
        End Sub

    End
    Class

  • Step five, write Signup code:
    Imports System.Data.OleDb 
    Public
    Class Signup
        Dim Da As OleDbDataAdapter
        Dim dS As DataSet
        Dim SqlString As String
        Private Sub Button1_Click(ByVal senderAs System.Object, ByVal e As System.EventArgs)Handles Button1.Click
            constring.Open()
            SqlString = "insert into info2 values("
            SqlString += """" & TextBox1.Text & """"
            SqlString += ","
            SqlString += """" & TextBox2.Text & """"
            SqlString += ","
            SqlString += """" & ComboBox1.Text & """"
            SqlString += ","
            SqlString += """" & TextBox3.Text & """"
            SqlString += ")"
            Dim DaAs New OleDbDataAdapter
            If (TextBox3.Text = TextBox4.Text)Then
                Da.InsertCommand = New OleDbCommand(SqlString, constring)               Da.InsertCommand.ExecuteNonQuery()    
                MessageBox.Show("record inserted successfully")   
            Else          
      MessageBox.Show("re enter password")   
            End If
         
        End Sub

    End
    Class

    Output:

       output1.gif

    output2.gif
      

          

Login to add your contents and source code to this article
share this article :
post comment
 

Super tutorial...easy to understand...like a mother teach to the child...

Posted by Gopinath JM Mar 30, 2012

great tutorial sir,, ahm sir can you also make tutorial for making a login history,, which records the user who loged in and if he modify the program like if he edit delete etc on the system then it will besaved on the database?

Posted by shann arceo Jan 20, 2012

keep it

Posted by praise jonathan Sep 12, 2011

very nice and helpful article

Posted by Shalini Juneja Apr 26, 2011
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Team Foundation Server Hosting
Become a Sponsor