An unhandled exception of type 'System.InvalidOperationException' occurred in system.windows.forms.dll
Additional information: Invalid attempt to Read when reader is closed.
using vb.net
also, when i run the code and click login, amsgbox is supposed to come out saying invalid login if it's wron...well..tht happens but when i click ok it does not go away
MsgBox("Invalid user name or password! Please try again.", MsgBoxStyle.OKOnly = MsgBoxStyle.OKOnly, "Invalid login!")
2006-07-24
02:30:06
·
2 answers
·
asked by
braich_gal
3
in
Computers & Internet
➔ Programming & Design
the program is supposed to read n compare the username & paswrd with the ones in the textbox...it it's a match then go to to the welcome form...
Dim Login As New Login
Dim Welcome As New Welcome
OleDbConnection1.Open()
Dim myOleDbReader As System.Data.OleDb.OleDbDataReader
myOleDbReader = OleDbCommand1.ExecuteReader()
While myOleDbReader.Read()
Dim username As String = myOleDbReader("User Name")
Dim password As String = myOleDbReader("Password")
If txtUserName.Text = username And txtPassword.Text = password Then
OleDbConnection1.Close()
myOleDbReader.Close()
Login.Close()
Welcome.Show()
Else
MsgBox("Invalid user name or password! Please try again.", MsgBoxStyle.OKOnly = MsgBoxStyle.OKOnly, "Invalid login!")
txtUserName.Text = ""
txtPassword.Text = ""
2006-07-24
02:40:35 ·
update #1
End If
End While
2006-07-24
02:40:51 ·
update #2
ok i have managed to deal with the above error but when irun and it goes to the other page...the invalid msgbox also appears
how to solve this
Dim Login As New Login
Dim Welcome As New Welcome
OleDbConnection1.Open()
Dim myOleDbReader As System.Data.OleDb.OleDbDataReader
myOleDbReader = OleDbCommand1.ExecuteReader()
2006-07-24
02:50:54 ·
update #3
While myOleDbReader.Read()
Dim username As String = myOleDbReader("User Name")
Dim password As String = myOleDbReader("Password")
If txtUserName.Text = username And txtPassword.Text = password Then
Login.Close()
Welcome.Show()
Else
MsgBox("Invalid user name or password! Please try again.", MsgBoxStyle.OKOnly = MsgBoxStyle.OKOnly, "Invalid login!")
txtUserName.Text = ""
txtPassword.Text = ""
End If
End While
OleDbConnection1.Close()
myOleDbReader.Close()
2006-07-24
02:51:18 ·
update #4
System.InvalidOperationException error solved
2006-07-24
03:02:28 ·
update #5
problem with invalid msgbox which appears even when i manage to ge to the next page
2006-07-24
03:03:43 ·
update #6