How to Make Log In Form with SQL Statement using VB.net

In This VB.Net Tutorial We Will See How to Make Log In Form with SQL Statement using VB.net

 Video Instruction:

Source Code: 

Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        End
    End Sub

    Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        Dim SQL As String
        Dim da As OleDb.OleDbDataAdapter
        Dim dt As New DataTable
        SQL = "SELECT * FROM tbl_Login WHERE User_Name='" & txtUser_Name.Text & "' AND PWD='" & txtPWD.Text & "'"
        da = New OleDb.OleDbDataAdapter(SQL, CNN)
        da.Fill(dt)
        If dt.Rows.Count > 0 Then
            'Have record, it mean can be log in
            'MsgBox("Log In Success")
            Form2.Show()
            Me.Hide()
        Else
            'No record
            MsgBox("User Name or Password Incorrect")
        End If
    End Sub

Before using code, Please make sure your connection to database is work fine 

Please click link How to Create Connection to Database with MS Access using VB.net

Post a Comment

0 Comments