Hi Bill,
I've continued investigating, and I now know what the
cause is:
after the line
ref = DmOpenDatabaseByTypeCreator(DM_TYPE,
DM_CREATOR, dmModeReadWrite);
I did a check of type
if(ref == NULL)
//some message
I commented out the above line and it now behaves
correctly.
Again, I know the cause - I didn't say I understand it
:-( ....but it works.
Thanks
Michel.P
--- Bill MacAdam <[EMAIL PROTECTED]> wrote:
> Do you have a file on the device which has the same
> name, but with a
> different creator id or type? If you do, you will
> not be able to create
> the database file. In other words, you cannot have
> two files with the
> same name with different creator ids on the same
> device.
>
> Bill MacAdam
> Visual Solutions
>
>
> -----Original Message-----
> From: Michel.P [mailto:michelpetrovic@;yahoo.com]
> Sent: Wednesday, October 30, 2002 3:08 PM
> To: Palm Developer Forum
> Subject: DmGetLastErr() inside function?
>
>
> Hello everyone,
>
> I have an odd (at least to me) problem with the
> database manager: even though
> DmOpenDatabaseByTypeCreator() returns 0 (which is
> correct because the DB doesn't exist),
> DmGetLastErr()
> returns 0 within the function.
>
> The code below never gets to the part where the DB
> is
> created, because 'err' never evaluates to anything
> else but 0.
> When I check the value of 'err' within the function,
> 'err' is always 0, but when the function returns
> 'err', it evaluates to 'dmErrCantFind' (by checking
> the value from the calling function).
>
> I can substitute
> if(err == dmErrCantFind)
> with
> if(err)
> and it still does the same.
>
> And if I "force" the code by creating the DB even
> though err == 0, I still get an error.
>
> I'm guessing I'm missing something trivial here.
> Any help would be much appreciated.
>
> Regards
> Michel.P
>
>
>
> static Err SecondFormInit()
> {
> Err err;
> DmOpenRef ref = NULL;
> ref = DmOpenDatabaseByTypeCreator(DM_TYPE,
> DM_CREATOR, dmModeReadWrite);
>
> if(!ref)
> {
> err = DmGetLastErr();
> if(err == dmErrCantFind)
> err = DmCreateDatabase(0, DM_NAME,
> DM_CREATOR,
> DM_TYPE, false);
>
> if(err)
> return err;
>
> ref = DmOpenDatabaseByTypeCreator(DM_TYPE,
> DM_CREATOR, dmModeReadWrite);
> if(!ref)
> err = DmGetLastErr();
> }
> db = ref;
> return err;
> }
__________________________________________________
Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/