Hello Everyone,
I am doing a Login Form that should be connected to MS Access 2010, and I had my guide from the following video:
Visual Basic Login Form Using Access Database Part 1 - YouTube
But it seems that there's no established connection ... ! The following is the code, I believe that the problem is with the extension of the database; where my database's extension is [ .accdb ], how can I fix it?
I am doing a Login Form that should be connected to MS Access 2010, and I had my guide from the following video:
Visual Basic Login Form Using Access Database Part 1 - YouTube
But it seems that there's no established connection ... ! The following is the code, I believe that the problem is with the extension of the database; where my database's extension is [ .accdb ], how can I fix it?
Public Class Form1 Dim loginError As String 'Problem with the 'login. Public Function Login() Dim DBConn As New ADODB.Connection 'Connection to the DB Dim User As New ADODB.Recordset 'passing out the args Dim UserName As String 'our query Dim UserDB As String 'get the user name Dim PassDB As String 'get the password Dim UserFound As Boolean 'some kind of a loop to check if the user exists in the database DBConn.Open("Provider = Microsoft.Jet.OLEDB.4.0;" & _ "Data Source = '" & Application.StartupPath & "\LoginDB.accdb'") User.Open("UserTable", DBConn.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic) UserFound = False Login = False UserName = "UserName = '" & TextBox1.Text & "'" Do User.Find(UserName) If User.BOF = False And User.EOF = False Then UserDB = User.Fields("UserName").Value.ToString PassDB = User.Fields("Password").Value.ToString If UserDB <> TextBox1.Text Then User.MoveNext() Else UserFound = True If PassDB = TextBox2.Text Then User.Close() DBConn.Close() Return True Else loginError = "Invalid Password, Please Check it" User.Close() DBConn.Close() Return False End If End If Else loginError = "Invalid Username, Please Check it!" User.Close() DBConn.Close() Return False End If Loop Until UserFound = True User.Close() DBConn.Close() Return False End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If Login() = True Then MessageBox.Show("Logged On!", "Login Message") Else MessageBox.Show(loginError, "Login Message") End If End Sub End Class
Last edited by a moderator: