Symbianos Series 60 Learning Notes 3: Probe into the Database

zhaozj2021-02-16  94

Symbian OS in Series 60 provides a database engine

You need to use the library EDBMS.LIB EFSRV.LIB when you use it.

Contains header file D32DBMS.H f32file.h

Set database file path

_LIT (KfileName, "C: //Test.db");

1. Create a database file:

/ / Establish a table's SQL statement

_LIT (KsqlcreateTable, "Create Table Notesentry (ID Counter, Note Varchar, alarm varchar, private varchar);

RFS fssession = ieikonenv-> fssession ();

RdbnameddataBase Database;

User :: Leaveiferror (fssession.connect ());

User :: Leaveiferror (Database.create (fssession, kfilename);

User :: Leaveiferror (Database.execute (ksqlcreatetable);

Database.Close ();

Fssession.close ();

2. Insert or modify the record

// SQL statement

_LIT (KSQL, "Insert Into Notesentry (Note, Alarm, Private) VALUES ('s', 's', 's');

or

_LIT (KSQL, "Update Notesentry Set Note = '90'");

RDBS RDBS;

RdbnameddataBase Database;

User :: leaveiferror (rdbs.connect ());

User :: Leaveiferror (Database.open (RDBS, KFileName);

User :: Leaveiferror (Database.execute (KSQL));

Database.Close ();

RDBS.Close ();

3. View Record

_LIT (KsqlQueryTable, "SELECT ID, NOTE, ALARM, Private from Notesentry);

RDBS RDBS;

RdbnameddataBase Database;

User :: leaveiferror (rdbs.connect ());

User :: Leaveiferror (Database.open (RDBS, KFileName);

RDBVIEW View;

User :: Leaveiferror (View.Prepare (Database, TDBQuery (KsqlQueryTable, EdbComparenormal));

User :: leaveiferror (view.evaluateall ());

View.firstl (); view.axt (); view.nextl ())

{

View.getl ();

Tuint32 id = view.coluint32 (1);

}

VIEW.CLOSE ();

Database.Close ();

RDBS.Close ();

转载请注明原文地址:https://www.9cbs.com/read-11569.html

New Post(0)