I'm trying to use this code to create a database:
Code:void CDatabaseHandler::CreateDatabase(const TDesC& aDatabaseFileName) { // construct a file store object - the file to contain the // database replaces any existing file of the same name. CFileStore* store = CPermanentFileStore::ReplaceLC(fsSession,aDatabaseFileName,EFileRead|EFileWrite); // Complete file store creation store->SetTypeL(store->Layout()); // Create a database in the store RDbStoreDatabase database; TStreamId id=database.CreateL(store); // NB. The database won't be closed on failure // Cleanup can be done; more usually database objects // are not automatic variables. // Keep database id as root of store store->SetRootL(id); // Complete database creation by commiting the store store->CommitL(); // create the tables CreatePhoneTable(database); // create an index //doCreateIndexL(database); // close the database database.Close(); // Do not commit store: database has taken control of commit CleanupStack::PopAndDestroy(); }when I call this function:Code:void CDatabaseHandler::CreatePhoneTable(RDbStoreDatabase database){ _LIT(KCol1Imei, "IMEI"); _LIT(KCol2Imsi, "IMSI"); _LIT(KPhoneT, "Phone"); CDbColSet* columns=CDbColSet::NewLC(); // add the columns // text columns default to 15 characters (variable length) //imei column TDbCol imei(KCol1Imei,EDbColText,15); imei.iAttributes=TDbCol::ENotNull; columns->AddL(imei); //imsi column TDbCol imsi(KCol2Imsi,EDbColText,15); imsi.iAttributes=TDbCol::ENotNull; columns->AddL(imsi); // Create Phone table User::LeaveIfError(database.CreateTable(KPhoneT,*columns)); // cleanup the column set CleanupStack::PopAndDestroy(); }
_LIT(appFile6, "c:\\System\\Data\\Test\\test.db");
cbDatabaseHandler.CreateDatabase(appFile6);
my app gets a System error... Compilation is ok, but when i try to run it i get this error....
What's wrong? This is my first time with database in symbian..any tips??
:mrgreen:

Reply With Quote

