I display the data to be edited as follows
private void carryOutNameSearch(TextBox theInputScreen, Form theOutputForm, int formType)
{
listOfIDs = new Vector(); // save IDs of records in case we want to delete
theOutputForm.deleteAll(); // clear the form
try
{
//RecordStore
rs = RecordStore.openRecordStore("Detail", true);
// Use the inner class so that the enumeration only gives
// us those records with a matching name.
RecordEnumeration re = rs.enumerateRecords(new NameMatcher(theInputScreen.getString()), null, false);
while (re.hasNextElement())
{
int id = re.nextRecordId();
listOfIDs.addElement(new Integer(id));
byte [] recordBuffer = rs.getRecord(id);
String record = new String(recordBuffer);
// extract the name and the age from the record
int endOfName = record.indexOf(";");
int endOfDesc = record.indexOf(";" , endOfName + 1);
int endOfTown = record.indexOf(";", endOfDesc + 1);
int endOfPlace = record.indexOf(";", endOfTown + 1);
int endOfStartDate = record.indexOf(";", endOfPlace + 1);
int endOfEndDate = record.indexOf(";", endOfStartDate + 1);
// int endOfSDay = record.indexOf("/", endOfPlace +1);
// int endOfSMonth = record.indexOf("/",endOfSDay + 1);
//int endOfSYear = record.indexOf(";", endOfSMonth + 1);
//int endOfEDay = record.indexOf("/", endOfSYear + 1);
//int endOfEMonth = record.indexOf("/", endOfEDay + 1);
//int endOfEYear = record.indexOf(";", endOfEMonth + 1);
int endOfComment = record.indexOf(";", endOfEndDate + 1);
int endOfRating = record.indexOf (";", endOfComment + 1);
int endOfReview = record.indexOf (";", endOfRating + 1);
String Name = record.substring(0, endOfName);
String Desc = record.substring(endOfName + 1, endOfDesc);
String Town = record.substring(endOfDesc + 1, endOfTown);
String Place= record.substring(endOfTown + 1, endOfPlace);
String SDate = record.substring(endOfPlace + 1, endOfStartDate);
String EDate = record.substring(endOfStartDate + 1, endOfEndDate);
// String SDay = record.substring(endOfPlace +1, endOfSDay);
// String SMonth = record.substring(endOfSDay + 1, endOfSMonth);
//String SYear = record.substring(endOfSMonth + 1, endOfSYear);
//String EDay = record.substring(endOfSYear + 1, endOfEDay);
//String EMonth = record.substring(endOfEDay + 1, endOfEMonth);
//String EYear = record.substring(endOfEMonth + 1, endOfEYear);
String Comment = record.substring(endOfEndDate + 1, endOfComment);
String Rating = record.substring(endOfComment + 1, endOfRating);
String Review = record.substring(endOfRating + 1, endOfReview);
if( formType == 0)
{
theOutputForm.append("\nEvent Name; " + "\n" + Name + "\n"
+ "Description; " + Desc + "\n"
+ "Town; " + Town + "\n"
+ "Place; " + Place + "\n"
+ "Start Date; " + SDate+ "\n"
+ "End Date; " + EDate + "\n"
+ "Comment; " + Comment + "\n"
+ "Event Rating; " + Rating + "\n"
+ "Overall Review; " + Review);
}
else
{
EtxtName = new TextField("Name of Event: ", Name, 15, TextField.ANY);
EdescEvent = new TextField("Describe the Event : ", Desc, 250, TextField.ANY);
EtownEvent = new TextField("Name of Town : ", Town, 50, TextField.ANY);
EplaceEvent = new TextField("Name of Place : ", Place, 25, TextField.ANY);
EditStartDate = new DateField("Start Date ", DateField.DATE);
EditEndDate = new DateField("End Date : ", DateField.DATE);
EcommentEvent = new TextField("Any comments : ", Comment, 300, TextField.ANY);
EEventRating = new TextField("Event Rating : ", Rating, 10, TextField.ANY);
EOverallReview = new TextField("Overall Review : ", Review, 300, TextField.ANY);
// EditStartDate.setDate(SDate);
//EditEndDate.setDate(EDate);
theOutputForm.append(EtxtName);
theOutputForm.append(EdescEvent);
theOutputForm.append(EtownEvent);
theOutputForm.append(EplaceEvent);
theOutputForm.append(EditStartDate);
// Editrecord.append("Start Date; " + SDay + "/" + SMonth + "/" + SYear);
//Editrecord.append("End Date; " + EDay + "/" + EMonth + "/" + EYear);
theOutputForm.append(EditEndDate);
theOutputForm.append(EcommentEvent);
theOutputForm.append(EEventRating);
theOutputForm.append(EOverallReview);
}
}
rs.closeRecordStore();
}
catch(Exception e)
{
mAlertConfirmDetailsSaved.setString("Couldn't read details");
System.err.println("Error accessing database");
}
Display.setCurrent(theOutputForm);
}
I have this update mehthod that does work with the other text fields.
protected void PerformUpdate()
{
//int id;
byte [] detailsBuffer = null;
strEName = EtxtName.getString();
strEDescEvent = EdescEvent.getString();
strETown = EtownEvent.getString();
strEPlace = EplaceEvent.getString();
//strStartDate = EditStartDate.getString();
//strEndDate = EEndDate.getString();
strStartDate = EditStartDate.getDate().toString();
strEndDate = EditEndDate.getDate().toString();
strECommentE = EcommentEvent.getString();
strERating = EEventRating.getString();
strEReview = EOverallReview.getString();
String detailsToUpdate = strEName + ";"+
strEDescEvent + ";"+
strETown + ";"+
strEPlace + ";"+ "\n"+
strEStartDate + ";"+ "\n"+
strEEndDate + ";"+
strECommentE + ";"+
strERating + ";"+
strEReview + ";";
if (listOfIDs != null)
{
try {
rs = RecordStore.openRecordStore("Detail", true);
for (Enumeration e = listOfIDs.elements() ; e.hasMoreElements() ;) {
int id = ((Integer)e.nextElement()).intValue();
// /rs.getRecord(editID, detailsBuffer, 0);
//{
detailsBuffer = detailsToUpdate.getBytes();
rs.setRecord(id,detailsBuffer, 0, detailsBuffer.length);
//rs.deleteRecord(id);
}
rs.closeRecordStore();
mAlertDeleteDone.setString(" Selected record Updated");
}
catch(Exception e)
{
mAlertDeleteDone.setString("Couldn't update record");
System.err.println("Error accessing database");
}
}
else
{
mAlertDeleteDone.setString("No records to delete");
}
Display.setCurrent(mAlertDeleteDone, mOpeningForm);
}
But when the update is run the textfields are changed but the datefield value is updated to null and can not be changed.
Am I missing something please help.