I have a form in which I have made File no field which hold the Integer value like 1-2-3-4 and so on.
I want that ,when I save a form which has file no 1 ,and then after when I want to save the next record it should remember the last file no and increment by 1.Also remembers the number after the application has been restarted.
I managed to do what I wanted BUT...
It only happens till the application is open and I'm saving data one after one...as soon as I close to application and opens in again I have see the last file no and enter the next file no manually.
I want that ,when I save a form which has file no 1 ,and then after when I want to save the next record it should remember the last file no and increment by 1.Also remembers the number after the application has been restarted.
Code:
String filenostr = filenotxtfield.getText();
statement.setString(1,filenostr);
int fileno=Integer.parseInt(filenostr);
fileno++;
String convertno=String.valueOf(fileno);
filenotxtfield.setText(convertno);
statement.executeUpdate();
int rowsAffected = statement.executeUpdate();
if(rowsAffected > 0)
{
JOptionPane.showMessageDialog(null, "Data Inserted successfully!");
}
else
{
JOptionPane.showMessageDialog(null, "Data is not Inserted!", "Not successfully", JOptionPane.ERROR_MESSAGE);
}
statement.close();
con.close();
It only happens till the application is open and I'm saving data one after one...as soon as I close to application and opens in again I have see the last file no and enter the next file no manually.