Imports System.Data
Imports System.Data.OleDb
Imports System
Imports System.Windows.Forms
Public Class LoginForm1
Dim db As New ADODB.Connection
Dim rs As New ADODB.Recordset
Public Sub searchdb()
If Not rs.EOF Then
If rs.Fields("UserName").Value = Trim(UsernameTextBox.Text) Then
If rs.Fields("Password").Value = Trim(PasswordTextBox.Text) Then
Dim Mac As New MainForm1
AccessLevel = rs.Fields("Level").Value
Mac.Show()
rs.Close()
db.Close()
Me.Hide()
Else
rs.MoveNext()
If rs.EOF Then
MessageBox.Show("Invalid Password or Username", "warning!!")
PasswordTextBox.Focus()
PasswordTextBox.SelectionStart = 0
PasswordTextBox.SelectionLength = Len(PasswordTextBox.Text)
Else
searchdb()
End If
End If
Else
rs.MoveNext()
If rs.EOF Then
MessageBox.Show("Invalid Password or Username", "warning!!")
UsernameTextBox.Focus()
UsernameTextBox.SelectionStart = 0
UsernameTextBox.SelectionStart = Len(UsernameTextBox.Text)
Else
searchdb()
End If
End If
Else
rs.MoveFirst()
End If
End Sub
Private Sub LoginForm1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim response As MsgBoxResult
response = MsgBox("Are you sure you want to close this application?", _
vbYesNo + vbExclamation + vbApplicationModal + _
vbDefaultButton2, "Close confirmation")
If response = MsgBoxResult.Yes Then
Me.Visible = False
Me.Dispose()
Me.Close()
End
ElseIf response = MsgBoxResult.No Then
e.Cancel = True
Exit Sub
End If
End Sub
Private Sub LoginForm1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
db.Open("Provider=microsoft.jet.oledb.4.0;data source=\\serve_path\database_ko.dll;OLE DB Services = 0;Jet OLEDB
![Big Grin :D :D](/images/smilies/biggrin.gif)
atabase Password=passwordko")
rs.Open("tbluser", db, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)
rs.MoveFirst()
End Sub
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Call searchdb()
End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
Application.Exit()
End Sub
End Class