Chapter 6. Using Symbian SQL

Armed with an understanding of the key concepts described in previous chapters, you should now be ready to dive in and look at how to use Symbian SQL in your app. This chapter discusses the key classes – RSqlDatabase and RSqlStatement – and covers supporting and utility classes. All APIs discussed in this chapter are declared in the Symbian SQL header file sqldb.h.

The Database Connection Class

The RSqlDatabase class provides key APIs for managing databases. In this section, we discuss how to connect to a database, create and delete databases, attach multiple databases to a single connection, execute SQL, and set and retrieve database parameters.

Connecting and Disconnecting

In order to access a database, you must first establish a connection to it. When you have finished accessing the database, you must then close the connection. Symbian provides the RSqlDatabase class to represent a database connection. You open a connection to a database by calling the Open() API on the connection object. Two variants of this API are provided, one leaving and one not:

TInt Open(const TDesC& aDbFileName, const TDesC8* aConfig=NULL);
void OpenL(const TDesC& aDbFileName, const TDesC8* aConfig=NULL);

The argument aDbFileName is the name of the database. If the filename is not valid or the file does not exist, the API returns an error. It is also an error if the connection is open already. The argument aConfig is an optional text descriptor which may contain configuration options. ...

Get Inside Symbian SQL: A Mobile Developer's Guide to SQLite now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.