VK LABELS

Saturday, 15 March 2014

Check data in Login Form

Check data in Login Form:

Imports System.Data
Imports Oracle.DataAccess.Client 
Imports Oracle.DataAccess.Types

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If UsernameTextBox.Text = "" Then
            MsgBox("Please Type UserName")
        ElseIf PasswordTextBox.Text = "" Then
            MsgBox("Please Type Password")
        ElseIf UsernameTextBox.Text = "Admin" And PasswordTextBox.Text = "Admin123" Then
            Form2.Show()
        Else
            Using conn = Opencon()
                Dim cmd As New OracleCommand
                cmd.Connection = conn
                cmd.CommandText = "SELECT USERNAME,PASSWORD FROM LOGINDATA WHERE USERNAME='" & UsernameTextBox.Text & "' AND PASSWORD='" & PasswordTextBox.Text & "'"
                cmd.CommandType = CommandType.Text
                Dim dr As OracleDataReader
                dr = cmd.ExecuteReader()
                If dr.Read() Then
                    UsernameTextBox.Text = dr("USERNAME")
                    PasswordTextBox.Text = dr("PASSWORD")
                    Form2.show()
                Else
                    MsgBox("Please Type Correct UserName and PassWord")
                End If
            End Using
        End If
    End Sub


No comments:

Post a Comment