How to replace the .dat files with .db files
| Wed, 2005-12-21 06:20 | |
|
Dear All,
I am using the series 60 sdk 2.1, in which I am trying to replace the .dat files with .db files, Now I am trying to access the data (Read and Write) from the .db files. Basically What I have done is that, I have created the .db files, with proper data, with the help of dbms Example code. After creation of this .db file, I have put this .db file into the c\system\data\ENHANCED\PLUGINS, Now to read the .db file I have changed the ReadL(), The ReadL fucntion I have changed because it was written, to read the data from the .dat files, But in my case I have to read the data from the .db files Now what I see is that application is Crashing. The changes code is _LIT(KSQLStatement2,"select Notes from CDs where Artist='ROCK8'"); _LIT(KCol1, "Artist"); _LIT(KCol2, "Notes"); RFs fsSession; CleanupClosePushL(fsSession); User::LeaveIfError(fsSession.Connect()); RFile file2; CFileStore* store = CFileStore::OpenLC(fsSession,KRMContactsFile,EFileRead|EFileWrite); RDbStoreDatabase database; RDbView view2; User::LeaveIfError(view2.Prepare(database,TDbQuery(KSQLStatement2,EDbCompareNormal))); User::LeaveIfError(view2.EvaluateAll()); CDbColSet* colSet = view2.ColSetL(); // retrieve the 1 row view2.GetL(); // while the rowset is on this row, can use a TPtrC to // refer to any text columns TPtrC artist = view2.ColDes(colSet->ColNo(KCol1)); // and a stream for long columns RDbColReadStream in; TDbColNo col = colSet->ColNo(KCol2); // Ordiginal position of long column in.OpenLC(view2, col); //Added this code HBufC8* notes = HBufC8::NewL(view2.ColLength(col)); TPtr8 DataPtr = notes->Des(); in.ReadL(DataPtr,view2.ColLength(col)); User::LeaveIfError(file2.Write(DataPtr)); User::LeaveIfError(file2.Flush()); in.Close(); CleanupStack::PopAndDestroy(); file2.Close(); fsSession.Close(); CleanupStack::PopAndDestroy(2); // iItem, iFs } Please let me know what its failing, Well One intresting thing is that when I change the format of the .dat file to the .db in the _LIT and run the ReadL (), in this fucntion i just open the store. Then also it is crashing. Please let me know and guide me, whats the mistake I am doing as I am new to the Symbian OS. Thanks In Advance Ranjeet. |
|





