problem with login authentication

zacksofia

Member
Joined
Jul 10, 2005
Messages
10
Programming Experience
Beginner
hello guys,

I don't know what went wrong when I write this


Dim sql = "SELECT Stud_ID FROM STUDENT WHERE Stud_ID = ' " & txtstudID.Text & " ' AND password = ' " & txtPassword.Text & " ' "

cmd =
New OleDbCommand(sql, myConn)
myConn.Open()
Dim dr As OleDbDataReader = cmd.ExecuteReader()

Try

If dr.Read = FalseThen

MessageBox.Show("Authentication failed.")

Else

MessageBox.Show("Login successfully...")

' Assign this form's TextBox to the Object Variable

studID = txtstudID

studpass = txtPassword

studentmain.Show()

Me.Hide()

EndIf

Catch ex As Exception

MsgBox(ex.Message)


EndTry
myConn.Close()


the error keep pointing to Dim dr As OleDbDataReader = cmd.ExecuteReader(). Did I miss something?
 
What is the error msg that you get there? It warns you about what?
Waiting for your feedback

btw, try to change this line:
VB.NET:
[color=#0000ff]Dim[/color][size=2] sql = "SELECT Stud_ID FROM STUDENT WHERE Stud_ID = ' " & txtstudID.Text & " ' AND password = ' " & txtPassword.Text & " ' "
[/size]

to
VB.NET:
[color=#0000ff]Dim[/color][size=2] strSQL As String = "SELECT Stud_ID, password FROM STUDENT WHERE Stud_ID = ' " & txtstudID.Text & " ' AND password = ' " & txtPassword.Text & " ' "



Cheers ;)


[/size]
 
Hey there Kulrom,

the error keep giving me this msg
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll

by the way, i'm using MS Access as my database. is it because of my database or what? :(
 
Last edited:
Back
Top