The error message is pretty explicit:
ExecuteReader requires an open and available Connection. The connection's current state is closed.
That is saying - very clearly - that
myConnection
is not Open - so all you need to do is call
Open
on
myConnection
at the top of the method, and
Close
when you are finished with it.
But...it would be a much, much better idea to build a new OleDbConnection specifically for this method to use, Open it, Close it, and Dispose it all within the method. Sharing a connection can give a lot of problems later on when you try to use it again from a nested method and it complains that a command is already in use. A Using block is teh simplest way to do this:
Using Statement (Visual Basic)[
^]
And two other very important things:
1) Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead. This kind of code in a login is just asking for trouble!
2) Never store passwords in clear text - it is a major security risk. There is some information on how to do it here:
Password Storage: How to do it.[
^] - the code is in C#, but it's pretty simple and easy to understand.