Move Back through a Java Database

Move Back through a Java Database

 

The code for the Previous button is similar to the Next button. But instead of using rs.Next, you use rs.Previous.

Return to the Design window and double click your Previous button to create a code stub.

Instead of typing out all that code again, simply copy and paste the code from your Next button. Then change the rs.Next, in the IF statement to rs.Previous. Change the rs.Previous in the ELSE part to rs.Next. You can also change your error message text from “End of File” to “Start of File”.

Your code should look like this:

Java code that moves back through a ResultSet

Run your programme again. You should be able to move backward and forward through the database by clicking your two buttons.

 

Advertisements

Give A message for us

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s