vendredi 11 décembre 2015

How to select next record and previous record in SQLite?

I have been searching like forever

so here's my code

    JButton btnNextLast = new JButton(">>");
    btnNextLast.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            try{
                String sQuery = "select * from accountinfo where rowid =  (SELECT MAX(rowid) FROM accountinfo)";
                PreparedStatement prst = connection.prepareStatement(sQuery);
                ResultSet rs = prst.executeQuery();
                lblSID.setText(rs.getString("sid"));
                lblfirst.setText(rs.getString("last"));
                lblLast.setText(rs.getString("first"));
                lblmiddle.setText(rs.getString("middle"));
                lblbirth.setText(rs.getString("birth"));
                lblcontact.setText(rs.getString("contact"));

            }catch(Exception qwe){

            }



        }
    });

I am using min and max for the last and and first record but how do I get the next record? I have a column name rowid it is the pk and auto incremented by one every time a user registers

Aucun commentaire:

Enregistrer un commentaire