Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to flush retrieved database values from form
    primarykey
    data
    text
    <p>I have been able to retrieve values into my form.The values are inserted into a table on save button click and are at the same time retrieved onto the same form too(on the same save click).But the problem now is that on each click the values are getting displayed in a continuous flow.I want to clear the screen(flush the values from form) after the previous click and display only the latest table state values. Heres the code i am working on:</p> <pre><code> public void fieldChanged(Field field, int context) //respond to button events { if (field == showInputButton) //if first button selected { Dialog.alert(TextField1.getText()); //show text from first input field try { //Open or create the database Database db = DatabaseFactory.openOrCreate("database1.db"); //Insert Data from db Statement statement1 = db.createStatement("INSERT INTO DirectoryItems(category_id,name,phone,email) VALUES ('1','"+TextField1.getText()+"','"+TextField2.getText()+"','"+TextField3.getText()+"')"); statement1.prepare(); statement1.execute(); statement1.close(); //Retrieve data try { add(new RichTextField("Attempting to retrieve data from " + "database1.db on the SDCard.")); Statement st = db.createStatement("SELECT name FROM DirectoryItems"); st.prepare(); Cursor c = st.getCursor(); Row r; int i = 0; while(c.next()) { r = c.getRow(); i++; add(new RichTextField(i + "Name = " + r.getString(0))); } if (i==0) { add(new RichTextField("No data in the DirectoryItems table.")); } st.close(); db.close(); } catch( Exception e ) { System.out.println( e.getMessage() ); e.printStackTrace(); } } </code></pre> <p>Does anyone know this.Please advise guys.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload