I hate Symbian Database
Login to reply to this topic.
Wed, 2004-01-14 13:26
Joined: 2003-08-11
Forum posts: 93
Well after a lot of fighting with the database engine of symbian and finding some problem and thank god was able to fix them. I am faced with a new one that i have no idea how to move around. I have a two databases and I read from one some information and insert into the other. Doing the inserting once and seeing the output of the other database works fine and the data has been moved normally. The problem is that when i try to enter data twice in arrow the second database is locked since I guess the insertion is still working on the database file. But i has returned from the function call. Closing the database doesn't work. Here is a sample of my insertion code.
Code:
_LIT(KSQLInsert, "SELECT Word, Definition FROM Words");
   view->Prepare((RDbDatabase&) *this,TDbQuery(KSQLInsert));
   view->InsertL();
   view->SetColL(1,Word);
   view->SetColL(2,Defintion);
view->PutL();
//Using the Begin and Commit style doesn't work either

/*TBuf<55> KSQLQuery;
KSQLQuery.Copy(_L("Insert into Words (Word,Definition) values ('','')"));//55 carecters
TInt Length=Word.Length();
Length+=Defintion.Length();
HBufC16* temp= HBufC16::NewLC(Length+55);
TPtr16 sql=temp->Des();
sql.Copy(KSQLQuery);
sql.Insert(sql.Locate('\'')+1,Word);
sql.Insert(sql.LocateReverse('\''),Defintion);
sql.ZeroTerminate();
Begin();
Execute(sql);
Commit();
CleanupStack::PopAndDestroy();*/
}
I am so stuck now if anyone has an idea please help me out with this.

Wed, 2004-01-14 14:19
Joined: 2003-01-14
Forum posts: 2133
Did you open a connection to the DBMS server and your database file before ?
Something like the code below should work :
Code:
   RDbNamedDatabase db;
   TBuf<255> query;
   User::LeaveIfError(db.Open(iDbs,KYourDatabase)); // iDBs is  connection to the DBMS server
   CleanupClosePushL(db);
   _LIT(KSQLQuery,"Insert into Words (Word,Definition) values ('%S','%S')"));
   query.Format(KSQLQuery,&Word,&Definition);
   db.Execute(query);
   CleanupStack::PopAndDestroy(); // db

(Note that - as you did -  using HBufC instead of TBuf is preferable )

Cheers,
Eric

Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Wed, 2004-01-14 14:30
Joined: 2003-08-11
Forum posts: 93
Sorry may be i didn't make myself clear. I have two view one with list and the other has txt editor. The first view displays the words and the second one displays the word and definition. The problem happens when i insert twice to another database. When i try going back to view the words that I have inserted in the other database and i try to open it It would return that it is already in use. This problems doesn't happen when i enter only once into the database it happens when i enter twice after each other. So I am not sure what the problem is but the words are inserted correctly but I have to close the application and then open it to see the words that I have added.
Thu, 2004-01-15 10:19
Joined: 2003-08-11
Forum posts: 93
Eric YOU ARE THE MAN!!! your advice althought I don't understand it really works. I changed my code to open the database with the RDbs instead of and RFs and it worx fine. The question WHY?? what makes it so diffrent.
Thu, 2004-01-15 10:46
Joined: 2003-01-14
Forum posts: 2133
The reason is that using the DBMS server adds a little bit of overhead but allow several entities to acces a same database simultaneously while using it directly through the file server locks it to the first views that opened it.

Cheers,
Eric

Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Mon, 2004-07-19 04:02
Joined: 2004-07-14
Forum posts: 2
HI, I have just starting learning symbian C++ and I have problems creating database. I'm really stuck. Hope that someone can help me in this.

Orginally i have this function to create database


RFs fsSession;
RDbNamedDatabase database;
void CNoteAppViewStub::CreateDB()
{
    _LIT(KDbFileName,"C:\\Symbian\\UIQ_70\\epoc32winscw\\c\\Documents\\VoiceCalendar\\vcalnotes.db");
    _LIT(KSQLCreateTable, "CREATE TABLE notesEntry(id COUNTER,note varchar,alarm varchar,private varchar)");

   User::LeaveIfError(fsSession.Connect());
   
  User::LeaveIfError(database.Create(fsSession, KDbFileName));
  User::LeaveIfError(database.Execute(KSQLCreateTable));
   
  database.Close();
   fsSession.Close();
}

However, i get this error msg:
Link Error   : Undefined symbol: 'int RFs::Connect(int) (?Connect@RFs@@QAEHH@Z)'


i have tried changing
RFs fsSession to RDbs fsSession, but i still encounter problems as followed :
illegal implicit conversion from 'RDbs' to 'RFs &'


What should i do to create a database?
Mon, 2004-07-19 05:29
Joined: 2003-10-08
Forum posts: 106
Quote
However, i get this error msg:
Link Error : Undefined symbol: 'int RFs::Connect(int) (?Connect@RFs@@QAEHH@Z)'

 Are you linking with efsrv.lib?

Quote
_LIT(KDbFileName,"C:\\Symbian\\UIQ_70\\epoc32winscw\\c\\Documents\\VoiceCalendar\\vcalnotes.db");

 This will most probably not work. Paths in the Symbian Environment (Emulator or Target) have to be relative to the disk setup. In other words, remove the Windows specific path and just leave c:\\Document\\VoiceCalendar\\vcalnotes.db.

Regards,
Varun

Mon, 2004-07-19 06:39
Joined: 2004-07-14
Forum posts: 2
Yup, i have link it with efsrv.lib

But the error still show::
Link Error   : Undefined symbol: 'int RFs::Connect(int) (?Connect@RFs@@QAEHH@Z)'
Wed, 2005-03-30 05:04
Joined: 2004-09-15
Forum posts: 24
hi XiaRiXue,
mayb its a late reply...
hav u re-build ur mmp files?


hope u olredi solved it anyway...

copyright 2003-2009 NewLC SARL