Hi all, My problem from last time is still with me unfortunately,
- I have a text field which you enter a name to search.
in my button i calling this method called displayCurrentRow()
private void displayCurrentRow()
{
//creating variable that will get colom values
String initials;
String nameDisp;
String surname;
String email;
String company;
String telephone;
String fax;
String physical_add;
String street_name;
String surburb;
String city;
String code;
String postal_add;
String post_str;
String post_surb;
String post_city;
String post_code;
String position;
int company_id;
int client_id;
name1=jTextField45.getText();
if(!"".equals(this.jTextField45.getText()))
{
jTextField45.setText(""); //Clear the textField after submiting.
String sql2 = "SELECT t1.client_id,t1.company_id,
t1.initials,t1.name,t1.surname,t1.email,
t1.position,t2.company_id,t2.company_name,
t2.phone,t2.fax,t2.physical_add," +
" t2.street_name,t2.surburb,t2.code,t2.city,
t2.postal_add,t2.post_str,t2.post_surb,t2.post_city,
t2.postal_code " +
"FROM client AS t1, company AS t2
WHERE t1.company_id = t2.company_id AND t1.name
LIKE '%"+name1+"%'";
int count =0; //extract one row
try
{
this.resultSet = this.connection.executeQuery(sql2);
while(this.resultSet.next())
{
//get the values from the database coloms values
assing them to the String variable
if(count == currentRow)
{
jButton15.setEnabled(true); //(Next Button)
jButton14.setEnabled(true);//(Prv Button)
//System.out.println(client_id);
initials = this.resultSet.getString(3);
nameDisp = this.resultSet.getString(4);
surname = this.resultSet.getString(5);
email = this.resultSet.getString(6);
position= this.resultSet.getString(7);
company = this.resultSet.getString(9);
telephone = this.resultSet.getString(10);
fax = this.resultSet.getString(11);
//displaying the results on the textField
jTextField27.setText(initials);
jTextField28.setText(nameDisp);
jTextField29.setText(surname);
jTextField33.setText(email);
jTextField31.setText(company);
jTextField32.setText(telephone);
jTextField34.setText(fax);
jTextField11.setText(position);
}
count++;
}
resultSet.close();
connection.close();
}
catch( SQLException e )
{
e.printStackTrace( System.err );
}
} //End of IF statement for name search value
}
- Then i call this methed displayCurrentRow() in my button "submit" which displays the data on the form,it works the data gets displayed.
- Then i have a method called nextPressed()
private void nextPressed()
{
currentRow++;
displayCurrentRow();
//displayCurrentRow();
}
This method is called in my button next, so when the button is cliked currentRow should increment then dispaly the next record.
i have the previous methed as well,but i am not gettting the results i need,my next button does nothing
Can someone spot what i am doing wrong.