Symbian3/SDK/Source/GUID-B38EBDBA-2A30-5595-9639-6AE58C530DCB.dita
changeset 0 89d6a7a84779
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Symbian3/SDK/Source/GUID-B38EBDBA-2A30-5595-9639-6AE58C530DCB.dita	Thu Jan 21 18:18:20 2010 +0000
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
+<!-- This component and the accompanying materials are made available under the terms of the License 
+"Eclipse Public License v1.0" which accompanies this distribution, 
+and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
+<!-- Initial Contributors:
+    Nokia Corporation - initial contribution.
+Contributors: 
+-->
+<!DOCTYPE task
+  PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
+<task xml:lang="en" id="GUID-B38EBDBA-2A30-5595-9639-6AE58C530DCB"><title>Creating a Database </title><shortdesc>This document shows you how to create a database for Symbian SQL. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody> <context id="GUID-9C6BDAAF-0547-51AF-8F47-5436C0D1697D"><p>Working with databases is not possible until the database exists. In this tutorial you will learn how to create a simple database. </p> <p>This tutorial uses code from the <xref href="GUID-C2FCE726-FD87-52BF-8AF8-7F54FB6D6CB1.dita">Basic SQL example application</xref>. </p> <p>The SQL statement used for this tutorial is shown here: </p> <codeblock id="GUID-EA0CADFD-53BF-5599-AD76-92EB15A94E9B" xml:space="preserve">CREATE DATABASE \\Basic_db.db</codeblock> </context> <steps id="GUID-65CD4149-1978-5FD9-84A3-ADACDE6C5B89"> <step id="GUID-3F8A65A1-7682-5C32-B92B-360CB923AA58"><cmd>Declare a constant to hold the database handle: </cmd> <info> <codeph>KDatabaseName</codeph> will be used when creating and accessing the database. </info> <stepxmp><codeblock id="GUID-7BAB1756-75A0-5C8A-B868-F8CD4BB3DEC1" xml:space="preserve">_LIT(KDatabaseName, "\\Basic_db.db");
+_LIT(KDatabaseMsg,"\nCreating a database\n");
+RSqlDatabase db;
+CConsoleBase* iConsole;</codeblock> </stepxmp> <stepresult>The objects and constants needed to create the database are now ready. </stepresult> </step> <step id="GUID-677801E7-CCEB-5158-9853-5BFC800BA6C2"><cmd>Create the database: </cmd> <info>You are telling Symbian SQL to execute the CREATE DATABASE command. </info> <stepxmp><codeblock id="GUID-D3D95DE0-2C19-5216-8160-1E92CC4D7F20" xml:space="preserve">iConsole-&gt;Printf(KDatabaseMsg);
+User::LeaveIfError(db.Create(KDatabaseName));
+iConsole-&gt;Printf(KDatabaseName);</codeblock> </stepxmp> <stepresult>The database now exists. <xref href="GUID-4688F6B7-E1B0-37CF-BAA2-C6BD103D4FDF.dita"><apiname>RSqlDatabase::Create()</apiname></xref> executes the SQL engine command that makes the actual database. You can look in the <filepath>C:\</filepath> drive on the device to confirm that the database object exists. </stepresult> </step> </steps> <result id="GUID-9814EF32-E1BA-52F3-8D2C-F1776D9EF8FE"><p>The database now exists. You can perform all the standard SQL operations on the database including creating and populating a table, querying the database, editing records and deleting the database, to name a few. </p> </result> <example id="GUID-4D518486-E7E1-57DB-AD33-CFFD29CA5DBA"><title>Create database example</title> <p>The following code snippet is from the example code used for this tutorial: </p> <codeblock id="GUID-2DD57F74-DEC1-54AC-82B8-9A186EF7E0B2" xml:space="preserve">...
+_LIT(KDatabaseName, "\\Basic_db.db");
+_LIT(KDatabaseMsg,"\nCreating a database\n");
+...
+CConsoleBase* iConsole;
+...
+void CBasicSqlExample::CreateDatabaseL()
+    {
+    RSqlDatabase db;
+
+    iConsole-&gt;Printf(KDatabaseMsg);
+    //create the database
+    User::LeaveIfError(db.Create(KDatabaseName));
+
+    iConsole-&gt;Printf(KDatabaseName);
+    CleanupClosePushL(db);
+    ...
+    }</codeblock> </example> <postreq id="GUID-762047BF-ED5B-51EF-9B90-2E7B0E8A8A89"><p>Now that you have created a database you need to add a table and populate it with some data. The following will show you how: </p> <ul><li id="GUID-FBF36438-2EC4-5E58-A70A-4C255B9315B6"><p> <xref href="GUID-1D35F788-A470-5269-93E0-7C33A0013489.dita">Creating a Table</xref>  </p> </li> <li id="GUID-53C27AF6-6B97-53AB-B72D-5BD92AB33BA8"><p> <xref href="GUID-CCB9C61B-FB28-5CD9-A366-4A9584097897.dita">Inserting Data into a Table</xref> </p> </li> <li id="GUID-7674D43E-0F60-5C6A-9D5D-4E007B6A9BEB"><p> <xref href="GUID-B9A3B17E-BDEB-5F66-968C-080335A721AC.dita">Writing from a Data Stream</xref>  </p> </li> </ul> </postreq> </taskbody><related-links><link href="GUID-22844C28-AB5B-5A6F-8863-7269464684B4.dita"><linktext>SQL Overview</linktext> </link> <link href="GUID-C2FCE726-FD87-52BF-8AF8-7F54FB6D6CB1.dita"><linktext>Basic SQL Example
+                Application</linktext> </link> </related-links></task>
\ No newline at end of file