Hi Im new here-I wanted to create a Login System. I am using Visual Basic 2008 Express Edition, Microsoft Access 2007/2010 Beta.
Ok this is my current code-the main problem I have is that I dont how to compare what the user puts into the textboxes and then check that against the data in my database.
Public Class LoginForm1 Dim inc As Integer Dim MaxRows As Integer Dim con As New OleDb.OleDbConnection Dim ds As New DataSet Dim da As OleDb.OleDbDataAdapter Dim sql As String Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click con.ConnectionString = "PROVIDER=Microsoft.JET.OLEDB.4.0;Data Source = D:\Work\Computing\Computing CourseWork\The Quiz DataBase.mdb" con.Open() If sql = "Select Username ID, Password FROM tblStudentLogin WHERE Username ID = UserName.Text AND Password = & PassWord.Text " Then MsgBox("You are now logged in " & UserName.Text) Me.Hide() StudentMainScreen.Show() Else MsgBox("Incorrect Login Details - Please try again.") End If con.Close() End Sub
When I run/debug the program and enter the correct username and password into the program it comes up with the MsgBox("Incorrect Login Details - Please try again.").
The connection string for where the database is coming from is right, because I checked it..so must be something wrong with the SQL Coding I guess. I honestly don't have a clue what's wrong with this code-according to my logic it makes sense, but maybe I'm missing some keyword or something? Please any help at all will be greatly appreciated!
Edited by TrueCoding: n/a