Do you know if I need to convert data to Hex to be able to write to a Database? 

I'm trying to save a record to a database and then retrieve, but when I load 
the application again and I try to retrieve the data, I only have an empty 
record.

This is my code to write when I quit the application. I'm using PODS
static void AppStop(void)
{
FormType*       pForm;
MemHandle       RecHandle;
MemPtr          RecPointer;
FieldType*   field_text;


        
pForm = FrmGetActiveForm();

field_text = FrmGetObjectPtr(pForm, FrmGetObjectIndex(pForm, MainNameField));
RecHandle=DmQueryRecord(ntDB, index);
RecHandle=DmNewRecord(ntDB, &index, FldGetTextLength(field_text));
RecPointer = MemHandleLock(RecHandle);
DmWrite(RecPointer, index , &field_text, FldGetTextLength(field_text));
MemPtrUnlock(RecPointer);
DmReleaseRecord(ntDB, index, true);
DmCloseDatabase(ntDB);
FrmCloseAllForms();
}

And this is my code when I start the App

static Err AppStart(void)
{
MemHandle       RecHandle;
MemPtr          RecPointer;
Char            *s;
Err                     error;

ntDB = DmOpenDatabaseByTypeCreator(DBType, CreatorID, dmModeReadWrite);
        if (!ntDB) 
        {
        error=DmCreateDatabase(0, DBName, CreatorID, DBType, false);
                if(error==0)
                ntDB = DmOpenDatabaseByTypeCreator(DBType, CreatorID, 
dmModeReadWrite);

                RecHandle=DmQueryRecord(ntDB, index);

                RecPointer = MemHandleLock(RecHandle);
                MemPtrUnlock(RecPointer);

        FrmGotoForm(MainForm);
        return errNone;
}

-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to