Mobile-Platform
BREW DATABASE CREATION
Here is a Sample Code Written for creation of database and inserting into table
static int Application3_CreateDb(Application3 * pMe){
const AECHAR *query =
L"CREATE TABLE test(customer VARCHAR(50),product VARCHAR(50));
INSERT INTO test(customer,product)VALUES('Q1','BREW');
INSERT INTO test(customer,product)VALUES('Q2','BREW');\0";
int tail =0;
if(ISHELL_CreateInstance(pMe->piShell,AEECLSID_Env,&pMe->piEnv)!=SUCCESS)
{
DBGPRINTF("STEP 1 ISHELL_CreateInstance FAILED\n");
return FALSE;
}
if(IEnv_CreateInstance(pMe->piEnv,dbc_AEECLSID_Factory,&pMe->piFact)!=SUCCESS)
{
DBGPRINTF("STEP 2 IEnv CreateInstance FAILED\n");
return FALSE;
}
if(dbc_IFactory_Open
(pMe->piFact, "fs:/~0x0065DD30/test2.db",dbc_CFLG_RWC | dbc_CFLG_WIDE,&pMe->piConn)!=AEE_SUCCESS)
{
DBGPRINTF("STEP 3 IFactory_Open FAILED\n");
return FALSE;
}
if(dbc_IConnection_CreateStatement16(pMe->piConn,query,&tail,&pMe->piStmt)!=SUCCESS)
{
DBGPRINTF("STEP 4 IConnection_CreateStatement16 FAILED\n");
return FALSE;
}
return TRUE;
}
Dont Forget to Add the following lines in ApplicationX_FreeAppData
if ( NULL != pMe->piStmt ) { // check for NULL first
dbc_IStatement_Release(pMe->piStmt);// release the interface
pMe->piStmt = NULL; // set to NULL so no problems later
}
if ( NULL != pMe->piConn ) { // check for NULL first
dbc_IConnection_Release(pMe->piConn);// release the interface
pMe->piConn = NULL; // set to NULL so no problems later
}
if ( NULL != pMe->piFact ) { // check for NULL first
dbc_IFactory_Release(pMe->piFact);// release the interface
pMe->piFact = NULL; // set to NULL so no problems later
}

Follow Me!