My application crashes on reading / writing data from the database. I have one database on c: and I copy-pasted and rename with different name. The following process is what I have used for copy...Please guide me if you have any suggestion or solution.
RFs fs;
fs.Connect();
CFileMan* fileMan=CFileMan::NewL(fs);
CleanupStack::PushL(fileMan);
TInt err=fileMan->Copy(anOld,aNew);
CleanupStack::PopAndDestroy(fileMan);
fs.Close();
if(err==KErrNone)
return ETrue;
else
return EFalse;
It crashes on following line when I am trying to insert or get any data from the database.
User::LeaveIfError( iDatabase.Execute( strSQL ) );
db creation:
TBool Open = OpenL();
if (!Open)
{
User::LeaveIfError(iDbSession.Connect());
CleanupClosePushL(iDbSession);
CleanupClosePushL(iDatabase);
User::LeaveIfError(iDatabase.Replace(iDbSession, iDBPath ));
// create table
_LIT(KSQLtest,"CREATE TABLE testtable(id INTEGER,test1 VARCHAR(50),test2 VARCHAR(50))"); User::LeaveIfError(iDatabase.Execute(KSQLtest));
iDatabase.Compact();
iDatabase.Close();
iDbSession.Close();
CleanupStack::PopAndDestroy();
CleanupStack::PopAndDestroy();
Open database:
User::LeaveIfError( iDbSession.Connect() );
CleanupClosePushL( iDbSession );
if ( KErrNone != iDatabase.Open(iDbSession, iDBPath))
{
iDbSession.Close();
CleanupStack::PopAndDestroy();
return EFalse;
}
else
{
CleanupClosePushL( iDatabase );
iIsDatabaseOpened = ETrue;
return ETrue;
}