English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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

2 answers

same thing as b4. you must use the 'New keyword' tp declare your reader.

2006-07-24 06:05:08 · answer #1 · answered by mr curious 2 · 0 0

Can you add a little more detail please. What program are you running when you get this? Is it from a web page? What are you trying to do when it happens?

Thanks

2006-07-24 09:35:51 · answer #2 · answered by dewcoons 7 · 0 0

fedest.com, questions and answers