Hi,
I'm working on a program that reads and writes to several databases, one of
which is the Memos database, and needed to write a utility function to fetch a
database's modification date. DmDatabaseInfo() looked like it would be a good
place to start. I noticed in the documentation that the modification date only
gets updated when the database is closed, so I wrote the utility function to
close and then re-open the database (and then check the modification date).
It seems to work fine on the emulator (running v3.5) and on a Sony Clie
(running v4.0) but on a Tungsten T3 (running 5.2.1) it doesn't work correctly,
and the problem only shows up on the Memos database! The problem appears to be
that the modification date gets modified by merely calling my utility function
(even though I don't think the function makes any changes to the database).
Here's the code in the utility function:
UInt32 DatabaseModifyTime(DmOpenRef *db)
{
UInt16 cardNo;
LocalID dbID;
UInt32 modTime = 0;
UInt16 openMode;
Err err;
err = DmOpenDatabaseInfo(*db, &dbID, NULL, &openMode, &cardNo, NULL);
if(err == 0)
{
DmCloseDatabase(*db);
*db = DmOpenDatabase(cardNo, dbID, openMode);
if(*db)
DmDatabaseInfo(cardNo, dbID, NULL, NULL, NULL, NULL,
&modTime, NULL, NULL, NULL, NULL, NULL, NULL);
}
return modTime;
}
Why would calling this function alter the database's modification date? (Any
why only on the T3, and only on the memos database?)
If I call this function several times in a row and display the returned time in
an alert after each call, I can see the value increase by the number of seconds
I wait before dismissing each alert. (Could something else on the system be
constantly tweeking the memos database?)
There's one more little twist - there's only one place in the program where the
memos database is opened - if that's changed from read/write access to read
only access, the problem still occurs! (AND, strangely enough, the openCount
that DmOpenDatabaseInfo() can return goes from 1 to 2 when I make this change?!)
The program isn't having any problems reading and writing data to the database
records. It's just the behavior of the modification date that's got me puzzled.
The above source code is fairly simple for clarity - I've also tried adding
lots of error checking and looking at additional output parameters for clues,
and everything looks normal, except for the openCount coming back as 2 in read
only mode.
Any ideas? (or is there an alternate way to do this?)
Thanks in advance,
Stephen
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/support/forums/