At 0:00 Uhr -0800 13.03.2000, Greg Winton wrote:
>Hello Marc,
>
>At 08:08 PM 3/8/00 +0100, you wrote:
>>Who has experiences with databases in shared-libraries? I try to
>  >generate a new database from a shared-library and to write records to
>>it, but it simple does not work.
>
>I have implemented a shared library that reads and writes from a database
>with no problem.  I know of no reason why reading/writing databases from a
>shared library should be any different than from an application.  Perhaps
>you could post a snippet of code for the implementation of SaveData and
>ReadData?
>
>Regards,
>Greg


Greg, thanks for the reply. Currently I want to generate database 
entries that are references by a unique "prefSelector", for example 
when I pass a prefSelector of 10, the following data contains the 
username for FTP access. Currently I just try to generate a new 
record in my database (which is successfully generated and opened 
through Prv_OpenDatabase). To make a new record and write some data I 
tried the following, but afther this the info dialog of the launcher 
application just indicates 0 records for my library's database. 
What's wrong with my code?

Err SetPref(UInt refNum, DWord clientContext, UInt prefSelector, 
VoidPtr prefContent)
{
ICSP_ClientContextPtr   contextP;
DmOpenRef       ICSP_DB;                // our database pointer
Err             error;
UInt            recordIndex = dmMaxRecordIndex; // always add new entrys at the
                                                // end of the database
VoidHand        recordH;
ICSP_PrefsStructPtr     nilP=0;
Char                    zero=0;
ULong                   length = 0;

        // Validate our parameters
        if ( prefSelector < ICSP_FirstSelector || prefSelector > 
ICSP_LastSelector)
                return ICSP_ErrInvalidSelector;

        // Make sure the library has been opened
        if ( !PrvIsLibOpen(refNum) )
                return( ICSP_ErrNotOpen );

        ICSP_DB = Prv_OpenDatabase();

        length =        sizeof ( prefSelector ) +
                                        StrLen ( (CharPtr) 
prefContent ) + 1; // add 1 for string terminator

        recordH = DmNewRecord( ICSP_DB, &recordIndex, length );

        if( recordH )
                {
                VoidPtr pDBRec = MemHandleLock( recordH );
                DmWrite( pDBRec, 0, prefContent, length );
                MemHandleUnlock( recordH );
                DmReleaseRecord( ICSP_DB, recordIndex, true );
                }

        error = DmResetRecordStates(ICSP_DB);
        if (error)
                ErrFatalDisplay("failed resetting ICSP_Lib record state");

        error = DmCloseDatabase(ICSP_DB);
        if (error)
                ErrFatalDisplay("failed cloasing ICSP_Lib database");

        ICSP_DB = 0;

        return( 0 );
}

-- 
Marc Mennigmann                               werkbank multimedia gmbh
PGP-Key RSA ID 0x12026CB9                     [EMAIL PROTECTED]
PGP-Key DSS ID 0xB79F9DB0                     http://www.werkbank.com

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to