Hello,

The coding below is just a simple login system, it checks whether the data in database (Access) is the same as what the user inserted via the JTextFields.

However, I'm having troubles when the data is incorrect, theoritically, as you can see by the program, a JOptionPane should popup & say incorrect, but alas, only a exception appears:

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state


try
            {
 
                String user = myuser.getText ();
                String pass = mypass.getText ();
 
                String sql = "SELECT COUNT(*) FROM LOGIN WHERE Username = '" + user + "' AND Password = '" + pass + "';";
 
                rs = stmt.executeQuery (sql);
                rs.beforeFirst ();
                rs.next ();
 
 
                int count = rs.getInt (1);
 
 
 
                if (count == 1)
 
                    {
 
                        myframe.setVisible (false);                    
                        myprofile.setVisible (true);
 
                    }
 
                else
 
                    {
                        JOptionPane.showMessageDialog (null, "Incorrect. Please retry or contact a game manager.");
                    }
 
 
            }
 
            catch (Exception e)
            {
                System.out.println ("Mybtn1 has encountered a error:");
                e.printStackTrace ();
            }
 
 
        }


Does anybody know what's wrong with the coding / could enlighten aything?

Thanks in advance
Shanse