Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim objConnection As New OleDb.OleDbConnection(
- "Provider=Microsoft.ACE.OLEDB.12.0;" &
- "Data Source=Login.accdb")
- Dim objDA As _
- New OleDb.OleDbDataAdapter("SELECT * FROM User", objConnection)
- Dim objCB As New OleDb.OleDbCommandBuilder(objDA)
- Dim objDS As New DataSet()
- Public Username, Password As String
- Dim UserFound As Boolean
- Private Sub frmLogin_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Retrieve()
- End Sub
- Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
- Username = txtUser.Text
- Password = txtPassword.Text
- For i As Integer = 1 To (objDS.Tables("User").Rows.Count)
- If CStr(objDS.Tables("User").Rows(i - 1).Item("Username")) =
- Username And
- CStr(objDS.Tables("User").Rows(i - 1).Item("Password")) = Password Then
- UserFound = True
- Me.Hide()
- MessageBox.Show("Welcome to the System!")
- frmStudents.Show()
- Exit For
- End If
- txtUser.Text = String.Empty
- txtPassword.Text = String.Empty
- Next
- If UserFound = False Then
- MessageBox.Show("Access Denied")
- End If
- End Sub
- Private Sub Retrieve()
- objDS.Clear()
- objDA.FillSchema(objDS, SchemaType.Source, "User")
- objDA.Fill(objDS, "User")
- End Sub
Add Comment
Please, Sign In to add comment