Vikal

  • Thread starter Thread starter Vikalsatya
  • Start date Start date
V

Vikalsatya

Guest
please check my code



Option Explicit On
Imports System.Data.OleDb

Public Class LOGIN
Dim objcon As New OleDbConnection
Dim strSql As String
Dim strconnection As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\HRMS\HRMS\Database1.accdb"
Dim da As New OleDb.OleDbDataAdapter
Dim ds As New DataSet
Dim Attempt As Integer = 0

Private Sub BTN_LOG_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTN_LOG.Click
Dim warning As String = "warning!" & vbNewLine & vbNewLine + _
"if Attempt var = 3" + vbNewLine + _
"system will shut down,"

If (TXT_US.Text = "") And (TXT_P.Text = "") Then
Attempt = Attempt + 1
MsgBox("please input user name and password!" & vbNewLine & vbNewLine + _
warning, MsgBoxStyle.Exclamation, " sorry sir!" & _
"now Attempt var= " & Attempt)

ElseIf (TXT_US.Text = "") Then
Attempt = Attempt + 1
MsgBox("please input user name!" & vbNewLine & vbNewLine + _
warning, MsgBoxStyle.Information, " sorry sir!" & _
"now Attempt var= " & Attempt)
ElseIf (TXT_P.Text = "") Then
Attempt = Attempt + 1
MsgBox("please input password!" & vbNewLine & vbNewLine + _
warning, MsgBoxStyle.Information, " sorry sir!" & _
"now Attempt var= " & Attempt)

Else
Dim strName = TXT_US.Text
Dim strPass = TXT_P.Text

With objcon
.Close()
If .State = ConnectionState.Closed Then
.ConnectionString = strconnection
.Open()
MsgBox("connectionsStat.open", MsgBoxStyle.Information, "Connected")
End If

End With

ds.Clear()
strSql = " Select * from TB_LOG Where Name ='" & TXT_US.Text & "' & And Pass ='" & TXT_P.Text & "'"

da = New OleDbDataAdapter(strSql, objcon)
da.Fill(ds, "TB_LOG")
If ds.Tables("TB_Log").Rows.Count <> 0 Then
MaximizeBox = True
MinimizeBox = True
MsgBox("Hello!" + strName + vbNewLine + _
"Log in successfully", MsgBoxStyle.OkOnly, _
"Welcome " + strName)
Else

MaximizeBox = False
MinimizeBox = False

Attempt = Attempt + _
MsgBox("OOP!-->" & strPass + vbNewLine + vbNewLine + _
" The user name or password you entred" + vbNewLine + _
" IS Not Valid," + vbNewLine + _
"Please Try again", MsgBoxStyle.Exclamation, "invalid")
End If

End If
If Attempt = 3 Then
MsgBox("window is shuting down....", MsgBoxStyle.Critical, "good bye sir")
Me.Close()

End If
End Sub
End Class

Continue reading...
 
Back
Top