×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    77

    database problem

    Hi all,

    when i add a row to the database , its adding to the database but the content is appearing twice (with diff. style). I'm sure that i'm adding data only once. And when i delete that row from the database i'm getting deleted confirmation . But its there still in the database with some extra stuff added to the database. One strange thing is when i queried for that perticular row in the database after deleting i'm getting zero results saying that no suitable data found.

    here i'm attaching code to create the database ,delete the database and the DB files before and after deletion.


    PLZ help me in solving the problem. PLZ .....

    //creating table

    void CAknExFormSaveForm::doMakeEventsDatabaseL(const TDesC& aDatabaseFileName)
    {
    CFileStore* store = CPermanentFileStore::ReplaceLC(fsSession,aDatabaseFileName,EFileRead|EFileWrite);
    store->SetTypeL(store->Layout());
    RDbStoreDatabase database;
    TStreamId id=database.CreateL(store);
    store->SetRootL(id);
    // Complete database creation by commiting the store
    store->CommitL();

    doCreateTableL(database);

    doCreateIndexL(database);
    database.Close();

    CleanupStack::PopAndDestroy();
    }


    //adding data to table

    _LIT ( aDatabaseFileName, "c:\\system\\apps\\GPS\\GPSEvents.db");
    _LIT(KSQLStatement,"select Area,Reminder from GPSEvents order by Area,Reminder");
    CFileStore* store = CFileStore::OpenLC(fsSession,aDatabaseFileName,EFileWrite|EFileShareAny);

    RDbStoreDatabase database;
    database.OpenL(store,store->Root());
    RDbView view;
    User::LeaveIfError(view.Prepare(database,TDbQuery(KSQLStatement,EDbCompareNormal)));
    User::LeaveIfError(view.EvaluateAll());

    view.InsertL();
    view.SetColL(1,Location);
    view.SetColL(2,reminderevent);
    view.PutL();
    view.Close();
    database.Close();
    CleanupStack::PopAndDestroy();


    //database file after addion

    P  ¡±pZZ Í |z @
    @i  € 
    @ 0 9@i  $GPSEventsArea 2 Reminder 2Ringer <  @ €  > y / @ \@i  $GPSEventsArea 2 Reminder 2Ringer <  $GPSEvents Area2 Reminder2  #€ €    &Atilde;  &pound; B 0 A m e e r p e t s s s s
    @ 1  @` ` A @@@PB @@@PB=@  l8AmeerpetssssJz:\SYSTEM\sounds\digital\dedodedo.wav @ *€  &para; &Atilde; w H W F


    //code for deleting that row

    _LIT(KSQLStatement1,"select Area,Reminder from GPSEvents where Area='Ameerpet'");
    TBuf<256> query(NULL);
    query.Append(KSQLStatement1);
    _LIT(aDatabaseFileName, "c:\\system\\apps\\GPS\\GPSEvents.db");
    CFileStore* store = CFileStore::OpenLC(fsSession,aDatabaseFileName,EFileRead|EFileWrite);

    RDbStoreDatabase database;
    database.OpenL(store,store->Root());

    RDbView view;
    User::LeaveIfError(view.Prepare(database,TDbQuery(query,EDbCompareNormal)));
    User::LeaveIfError(view.EvaluateAll());

    if(view.FirstL())
    {
    database.Begin();
    view.GetL();
    view.DeleteL();
    view.Reset();
    database.Commit();
    }

    view.Close();
    database.Close();
    CleanupStack::PopAndDestroy();


    //database file after deletion

    P  ¡±pZš ; 6&Atilde; @
    @i  € 
    @ 0 9@i  $GPSEventsArea 2 Reminder 2Ringer <  @ €  > y / @ \@i  $GPSEventsArea 2 Reminder 2Ringer <  $GPSEvents Area2 Reminder2  #€ €    &Atilde;  &pound; B 0 A m e e r p e t s s s s
    @ 1  @` ` A @@@PB @@@PB=@  l8AmeerpetssssJz:\SYSTEM\sounds\digital\dedodedo.wav @ *€  &para; &Atilde; w H W F
    @ 1 @ A @@@PB @@@PB@ @ *€  € $ &Atilde;  ¨ª ¨¹ €


    Here you'll find a row exist with Area Ameerpet even after deleting it with some extra data appended with.
    I encountred the same problem with SDK DBMS example.


    PLZ help me in solving this problem.
    Thanks in advance,

    rsridhar@valuelabs.net

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    39
    Hi,

    The extra lines in the database file you see when you open it in a text editor are probably database transaction entries. You can use RDbDatabase::Compact() to remove that.

    Brijesh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •