Hello everybody!

I'm trying to write an int from my Java-based conduit to the appInfo block
of one of my databases of my application but I don't seem to do it right.

Here is what I've done.

The code in my application:

typedef struct
{ 
UInt32 lastSyncDate; 
} MyAppInfoType; 

typedef MyAppInfoType* MyAppInfoPtr; 


/************************************************************ 
* 
*  FUNCTION: InitAppInfo 
* 
*  DESCRIPTION: Create an app info chunk if missing. 
* 
* PARAMETERS: database pointer 
* 
*  RETURNS: 0 if successful, errorcode if not 
* 
*************************************************************/ 
static Err InitAppInfo(DmOpenRef dbP) 
{ 
UInt16 cardNo; 
MemHandle h; 
LocalID dbID; 
LocalID appInfoID; 
MyAppInfoPtr appInfoP; 
MyAppInfoPtr nilP = 0; 


// We have a DmOpenRef and we want the database's app info block ID. 
// Get the database's dbID and cardNo and then use them to get the 
appInfoID. 

if (DmOpenDatabaseInfo(dbP, &dbID, NULL, NULL, &cardNo, NULL)) 
return dmErrInvalidParam; 

if (DmDatabaseInfo(cardNo, dbID, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
&appInfoID, NULL, NULL, NULL)) 
return dmErrInvalidParam; 


// If no appInfoID exists then we must create a new one. 
if (appInfoID == NULL) 
{ 
h = DmNewHandle (dbP, sizeof (MyAppInfoType)); 
if (! h) return dmErrMemError; 

appInfoID = MemHandleToLocalID (h); 
DmSetDatabaseInfo(cardNo, dbID, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
&appInfoID, NULL, NULL, NULL); 
} 


// Lock the appInfoID and copy in defaults from our default structure. 
appInfoP = MemLocalIDToLockedPtr(appInfoID, cardNo); 

// Clear the app info block. 
DmSet (appInfoP, 0, sizeof (MyAppInfoType), 0); 


// Initialize lastSyncDate.  This is actually redundant since the DmSet 
// call above has already set lastSyncDate to zero.  But this shows how 
// to set variables in addition to the categories. 
DmSet (appInfoP, (long)&nilP->lastSyncDate, sizeof(appInfoP->lastSyncDate), 
0); 

//Dr
awCount(appInfoP->lastSyncDate, x, y);

MemPtrUnlock(appInfoP);
return 0;
}


And, in my Java-based conduit I've written a function that writes to the
appInfo block:

/**Writes lastSyncDate to the AppInfo chunck of CounterDB.*/

public void
teToAppInfo(){ 
   int filehandle = 0; 
   String name = "CounterDB"; 
   byte[] data; 
   ConfigureConduitInfo user_ID = new ConfigureConduitInfo(); 
   UserInfo info; 

   try { 
     info = SyncManager.readUserID(user_ID.userId); 
     ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
     DataOutputStream out = new DataOutputStream(baos); 
     out.writeInt(info.lastSyncDate); 
     data = baos.toByteArray(); 
     out.close(); 
filehandle = SyncManager.openDB(name, 0, 
      SyncManager.OPEN_READ | 
SyncManager.OPEN_WRITE | 
SyncManager.OPEN_EXCLUSIVE); 
     SyncManager.writeDBAppInfoBlock(filehandle, name, data); 
SyncManager.closeDB(filehandle); 

  } catch (IOException e) { 
       Log.out("Could not write to AppInfo chunck!"); 
    } 
} 

With this code I'm simply trying to write the lastSyncDate to the appInfo 
block 
of my handheld database, but when I hotsync to let my conduit write this 
value, 
it doesn't seem to change.  When I display the value of lastSyncDate after a 
hotsync, I get the value 0, the same value as it was initialised to when the 
appInfo 
block was created on the handheld.  Could you help me in any way? 

I'd be so happy if you gave me some input! 

Kind regards, 

/Bulent Gecer 








-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to