Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

hello!
who can help me?
I don't know how to use the database to store the data?
who can give me a example?
thanks!

i am also looking one.if you find the ans tell me also

i am also looking one.if you find the ans tell me also

Hi Dinesh,
You can look into your Brew Examples dir
e.g. ......\BrewV11\Examples\idbusage
for IDatabase/IDBMgr Usages and examples...
~~~~~~
SoftEast
~~~~~~

Hi Dinesh,
You can look into your Brew Examples dir
e.g. ......\BrewV11\Examples\idbusage
for IDatabase/IDBMgr Usages and examples...
~~~~~~
SoftEast
~~~~~~

hi,
first of all thanks very much. provide me sdk1.1 examples

hi,
first of all thanks very much. provide me sdk1.1 examples

you please provide me brew sdk 1.1 example directory

you please provide me brew sdk 1.1 example directory

Download SDK from
https://brewx.qualcomm.com/brew/sdk/download.jsp
~~~~~~
SoftEast
~~~~~~

Download SDK from
https://brewx.qualcomm.com/brew/sdk/download.jsp
~~~~~~
SoftEast
~~~~~~

Go through Expense Tracker example in your SDK

Go through Expense Tracker example in your SDK

i have createed an example if you need that mail me @ [email]dinesh547verma@gmail.com/dineshv@mindfiresolutions.com[/email]

i have createed an example if you need that mail me @ [email]dinesh547verma@gmail.com/dineshv@mindfiresolutions.com[/email]

Hi guys,
what could be the possible reasons of failure of Idatabase_open apart from mif priveleges

Hi guys,
what could be the possible reasons of failure of Idatabase_open apart from mif priveleges

dear sir,
when i am inserting text into database i am gettting buffer overrun. when i reduce the length of text to insert into database , i am not getting that error.
-please reply soon , i was not able to debug why it happen? I want to enter a text of 50 characters in database
thanks
dilip kumar

dear sir,
when i am inserting text into database i am gettting buffer overrun. when i reduce the length of text to insert into database , i am not getting that error.
-please reply soon , i was not able to debug why it happen? I want to enter a text of 50 characters in database
thanks
dilip kumar

Hi
It seems there is some problem with buffer allocation/type of data you are trying to write in to the db.
Why don't you post your code for better help

Hi
It seems there is some problem with buffer allocation/type of data you are trying to write in to the db.
Why don't you post your code for better help

sir,
i have made two functions for reading and inserting data into database. the functions are as follows:-
static void createdatabase(tomogas* pMe, const char *dbname)
{
// 1. Usage: Basic IDB Usage
// This section tries to exercise each of the interface function
// all IDBMgr, IDatabase, IDBRecord interfaces atleast once.
// All the variables used in this example are defined within this
// code block.
IDBMgr * pIDBMgr = NULL;
IDBRecord * pIDBRecord1 = NULL;
IDBRecord * pIDBRecord2 = NULL;
IDBRecord * pIDBRec1 = NULL;
IDBRecord * pIDBRec2 = NULL;
int nRetVal = EBADFILENAME;
AEEDBField dbField1[2]; // data for record 1
AEEDBField dbField2[4]; // data for record 2
uint32 recordCount = 0; // number of records in the database
const char userName [] = "John kumar";
const char password [] = "Smith";
char *DistributorName = NULL;
const char agencyName[]="HP";
const char consumerno[] = "123456"; // consumerno value
const char DistributorNo[] = "98765432107"; // Home phone number
char szBuf[30] = {0}; // temp buffer for printing
uint16 fieldLen, recId = 0;
byte * data = NULL;
AECHAR * psz = NULL;
DistributorName = (char*) MALLOC( 100 * sizeof( char ) );
if( !DistributorName )
{
FREEIF( DistributorName );
DBGPRINTF ("//////////////////memory allocation failed");
return;
}
strcpy(DistributorName,"DAHISAR SERVICE");
DBGPRINTF("++++++++++++++++++++++++++++%s",DistributorName);
// Data fill values used to create database records.
// The parameter dbField1 is a two item array of type
// AEEDBField. Each array item corresponds to two fields
// in a record, respectively. The parameter dbField2 is
// a three item array of type AEEDBField. Each array item
// corresponds to the three fileds in the record, respectively.
//
// The first record will contain one feild for a first
// name and a second field for a last name of a person.
// The second record will contain one field for a last
// name, a second field for a consumerno, and a third
// field for a home phone number.
//
// Create IDBMgr object. This step needs to be done only if
// the IDBMgr object has not been created already.
ISHELL_CreateInstance(pMe->pIShell, AEECLSID_DBMGR, (void **)&pIDBMgr);
if (pIDBMgr == NULL)
return;
if ((pMe->pIDatabase = IDBMGR_OpenDatabase (pIDBMgr, dbname, FALSE))!= NULL)
{
// Release IDBMgr Interface and return.
IDBMGR_Release (pIDBMgr);
DBGPRINTF("////////////////////////////database exists");
return;
}
// Create a database.
if ((pMe->pIDatabase = IDBMGR_OpenDatabase (pIDBMgr, dbname, TRUE)) == NULL)
{
// Release IDBMgr Interface and return.
IDBMGR_Release (pIDBMgr);
DBGPRINTF("//////////////////////////// create failed");
return;
}
// Create two records. The first record has two fields
// and the second record has three fields.
if(STREQ("Logindb",dbname))
{
// Data fill record 1 field 1
dbField1[0].fName = AEEDBFIELD_TEXT;
dbField1[0].fType = AEEDB_FT_STRING;
dbField1[0].pBuffer = (void *)userName;
dbField1[0].wDataLen = STRLEN (userName);
// Data fill record 1 field 2
dbField1[1].fName = AEEDBFIELD_TEXT ;
dbField1[1].fType = AEEDB_FT_STRING;
dbField1[1].pBuffer = (void *)password;
dbField1[1].wDataLen = STRLEN (password);
pIDBRecord1 = IDATABASE_CreateRecord (pMe->pIDatabase, dbField1, 2);
// If anyone of the above records were not created, clean up and return.
if (pIDBRecord1 == NULL )
{
// Release any record that did get created.
DBGPRINTF("/////////////////////record creation failed");
IDBRECORD_Release (pIDBRecord1);
// IDATABASE_Release releases any database records that are
// still in the database, closes the open database files, and
// frees any memory associated with the database.
IDATABASE_Release (pMe->pIDatabase);
IDBMGR_Remove (pIDBMgr, dbname); // Remove DB file
IDBMGR_Release (pIDBMgr); // Release the DB manager
return;
}
// Since we reached here we have been able to create the
// records in the database. We should release the DBRecord
// interface pointers here since we don't plan to use them
// anymore.
//
IDBRECORD_Release (pIDBRecord1);
}
else
{
// Data fill record 2 field 1
dbField2[0].fName = AEEDBFIELD_TEXT ;
dbField2[0].fType = AEEDB_FT_STRING;
dbField2[0].wDataLen = STRLEN (DistributorName);
dbField2[0].pBuffer = (void *)DistributorName;
// Data fill record 2 field 2
dbField2[1].fName = AEEDBFIELD_TEXT ;
dbField2[1].fType = AEEDB_FT_STRING ;
dbField2[1].pBuffer = (void *)consumerno;
dbField2[1].wDataLen = STRLEN(consumerno);
// Data fill record 2 field 3
dbField2[2].fName = AEEDBFIELD_TEXT ;
dbField2[2].fType = AEEDB_FT_STRING ;
dbField2[2].pBuffer = (void *)DistributorNo;
dbField2[2].wDataLen = STRLEN(DistributorNo);
//Data fill record 2 field 4
dbField2[3].fName =AEEDBFIELD_TEXT ;
dbField2[3].fType=AEEDB_FT_STRING ;
dbField2[3].wDataLen=STRLEN(agencyName);
dbField2[3].pBuffer =(void *)&agencyName;
pIDBRecord2 = IDATABASE_CreateRecord (pMe->pIDatabase, dbField2, 4);
// If anyone of the above records were not created, clean up and return.
if (pIDBRecord2 == NULL )
{
// Release any record that did get created.
DBGPRINTF("/////////////////////record creation failed");
IDBRECORD_Release (pIDBRecord2);
// IDATABASE_Release releases any database records that are
// still in the database, closes the open database files, and
// frees any memory associated with the database.
IDATABASE_Release (pMe->pIDatabase);
IDBMGR_Remove (pIDBMgr, dbname); // Remove DB file
IDBMGR_Release (pIDBMgr); // Release the DB manager
return;
}
// Since we reached here we have been able to create the
// records in the database. We should release the DBRecord
// interface pointers here since we don't plan to use them
// anymore.
//
IDBRECORD_Release (pIDBRecord2);
}
// IDATABASE_Release: closes the open database files, and frees
// any memory associated with the database.
IDATABASE_Release (pMe->pIDatabase);
//IDBMGR_Remove (pIDBMgr, dbname); // Remove the database files.
IDBMGR_Release (pIDBMgr); // Release the DB manager

sir the problem is when i change the distributor name to "shalendra agency service " i.e is when the the length of distributor name is increased it returns buffer overrun. please reply soon . its very urgent
thanks

sir,
i have made two functions for reading and inserting data into database. the functions are as follows:-
static void createdatabase(tomogas* pMe, const char *dbname)
{
// 1. Usage: Basic IDB Usage
// This section tries to exercise each of the interface function
// all IDBMgr, IDatabase, IDBRecord interfaces atleast once.
// All the variables used in this example are defined within this
// code block.
IDBMgr * pIDBMgr = NULL;
IDBRecord * pIDBRecord1 = NULL;
IDBRecord * pIDBRecord2 = NULL;
IDBRecord * pIDBRec1 = NULL;
IDBRecord * pIDBRec2 = NULL;
int nRetVal = EBADFILENAME;
AEEDBField dbField1[2]; // data for record 1
AEEDBField dbField2[4]; // data for record 2
uint32 recordCount = 0; // number of records in the database
const char userName [] = "John kumar";
const char password [] = "Smith";
char *DistributorName = NULL;
const char agencyName[]="HP";
const char consumerno[] = "123456"; // consumerno value
const char DistributorNo[] = "98765432107"; // Home phone number
char szBuf[30] = {0}; // temp buffer for printing
uint16 fieldLen, recId = 0;
byte * data = NULL;
AECHAR * psz = NULL;
DistributorName = (char*) MALLOC( 100 * sizeof( char ) );
if( !DistributorName )
{
FREEIF( DistributorName );
DBGPRINTF ("//////////////////memory allocation failed");
return;
}
strcpy(DistributorName,"DAHISAR SERVICE");
DBGPRINTF("++++++++++++++++++++++++++++%s",DistributorName);
// Data fill values used to create database records.
// The parameter dbField1 is a two item array of type
// AEEDBField. Each array item corresponds to two fields
// in a record, respectively. The parameter dbField2 is
// a three item array of type AEEDBField. Each array item
// corresponds to the three fileds in the record, respectively.
//
// The first record will contain one feild for a first
// name and a second field for a last name of a person.
// The second record will contain one field for a last
// name, a second field for a consumerno, and a third
// field for a home phone number.
//
// Create IDBMgr object. This step needs to be done only if
// the IDBMgr object has not been created already.
ISHELL_CreateInstance(pMe->pIShell, AEECLSID_DBMGR, (void **)&pIDBMgr);
if (pIDBMgr == NULL)
return;
if ((pMe->pIDatabase = IDBMGR_OpenDatabase (pIDBMgr, dbname, FALSE))!= NULL)
{
// Release IDBMgr Interface and return.
IDBMGR_Release (pIDBMgr);
DBGPRINTF("////////////////////////////database exists");
return;
}
// Create a database.
if ((pMe->pIDatabase = IDBMGR_OpenDatabase (pIDBMgr, dbname, TRUE)) == NULL)
{
// Release IDBMgr Interface and return.
IDBMGR_Release (pIDBMgr);
DBGPRINTF("//////////////////////////// create failed");
return;
}
// Create two records. The first record has two fields
// and the second record has three fields.
if(STREQ("Logindb",dbname))
{
// Data fill record 1 field 1
dbField1[0].fName = AEEDBFIELD_TEXT;
dbField1[0].fType = AEEDB_FT_STRING;
dbField1[0].pBuffer = (void *)userName;
dbField1[0].wDataLen = STRLEN (userName);
// Data fill record 1 field 2
dbField1[1].fName = AEEDBFIELD_TEXT ;
dbField1[1].fType = AEEDB_FT_STRING;
dbField1[1].pBuffer = (void *)password;
dbField1[1].wDataLen = STRLEN (password);
pIDBRecord1 = IDATABASE_CreateRecord (pMe->pIDatabase, dbField1, 2);
// If anyone of the above records were not created, clean up and return.
if (pIDBRecord1 == NULL )
{
// Release any record that did get created.
DBGPRINTF("/////////////////////record creation failed");
IDBRECORD_Release (pIDBRecord1);
// IDATABASE_Release releases any database records that are
// still in the database, closes the open database files, and
// frees any memory associated with the database.
IDATABASE_Release (pMe->pIDatabase);
IDBMGR_Remove (pIDBMgr, dbname); // Remove DB file
IDBMGR_Release (pIDBMgr); // Release the DB manager
return;
}
// Since we reached here we have been able to create the
// records in the database. We should release the DBRecord
// interface pointers here since we don't plan to use them
// anymore.
//
IDBRECORD_Release (pIDBRecord1);
}
else
{
// Data fill record 2 field 1
dbField2[0].fName = AEEDBFIELD_TEXT ;
dbField2[0].fType = AEEDB_FT_STRING;
dbField2[0].wDataLen = STRLEN (DistributorName);
dbField2[0].pBuffer = (void *)DistributorName;
// Data fill record 2 field 2
dbField2[1].fName = AEEDBFIELD_TEXT ;
dbField2[1].fType = AEEDB_FT_STRING ;
dbField2[1].pBuffer = (void *)consumerno;
dbField2[1].wDataLen = STRLEN(consumerno);
// Data fill record 2 field 3
dbField2[2].fName = AEEDBFIELD_TEXT ;
dbField2[2].fType = AEEDB_FT_STRING ;
dbField2[2].pBuffer = (void *)DistributorNo;
dbField2[2].wDataLen = STRLEN(DistributorNo);
//Data fill record 2 field 4
dbField2[3].fName =AEEDBFIELD_TEXT ;
dbField2[3].fType=AEEDB_FT_STRING ;
dbField2[3].wDataLen=STRLEN(agencyName);
dbField2[3].pBuffer =(void *)&agencyName;
pIDBRecord2 = IDATABASE_CreateRecord (pMe->pIDatabase, dbField2, 4);
// If anyone of the above records were not created, clean up and return.
if (pIDBRecord2 == NULL )
{
// Release any record that did get created.
DBGPRINTF("/////////////////////record creation failed");
IDBRECORD_Release (pIDBRecord2);
// IDATABASE_Release releases any database records that are
// still in the database, closes the open database files, and
// frees any memory associated with the database.
IDATABASE_Release (pMe->pIDatabase);
IDBMGR_Remove (pIDBMgr, dbname); // Remove DB file
IDBMGR_Release (pIDBMgr); // Release the DB manager
return;
}
// Since we reached here we have been able to create the
// records in the database. We should release the DBRecord
// interface pointers here since we don't plan to use them
// anymore.
//
IDBRECORD_Release (pIDBRecord2);
}
// IDATABASE_Release: closes the open database files, and frees
// any memory associated with the database.
IDATABASE_Release (pMe->pIDatabase);
//IDBMGR_Remove (pIDBMgr, dbname); // Remove the database files.
IDBMGR_Release (pIDBMgr); // Release the DB manager

sir the problem is when i change the distributor name to "shalendra agency service " i.e is when the the length of distributor name is increased it returns buffer overrun. please reply soon . its very urgent
thanks

Hi!
There are few things that u must correct.
The main reason of your problem is AEEDB_FT_STRING. it expects AECHAR data type and you are giving char to it. Convert it into AECHAR
Try keeping most of the things on heap rather than stack e.g use
AEEDBField *PDbField = (AEEDBField *) MALLOC(sizeof(AEEDBField) * intNumFields);
For field names(dbField2[3].fName) its better to have your own enums as it helps in retrieving & manipulating data in DB
Hope it works :)

Hi!
There are few things that u must correct.
The main reason of your problem is AEEDB_FT_STRING. it expects AECHAR data type and you are giving char to it. Convert it into AECHAR
Try keeping most of the things on heap rather than stack e.g use
AEEDBField *PDbField = (AEEDBField *) MALLOC(sizeof(AEEDBField) * intNumFields);
For field names(dbField2[3].fName) its better to have your own enums as it helps in retrieving & manipulating data in DB
Hope it works :)

Try using AEEDBFIELD_FULLNAME insted of
AEEDBFIELD_TEXT ;

Try using AEEDBFIELD_FULLNAME insted of
AEEDBFIELD_TEXT ;

thanks very much Sir ,
my problem had solved. if there is problem in future i would require your help again. once again thanks very much
dillp kumar

thanks very much Sir ,
my problem had solved. if there is problem in future i would require your help again. once again thanks very much
dillp kumar

Hi guys, why not use ISQL posted in BREW website, it is a good extension as database component.

Hi guys, why not use ISQL posted in BREW website, it is a good extension as database component.

Hello Tenz,
We are using the ISQL extension .
but while running the sample aplication of ISQL we are getting crash on the Device anywhere on device LG8500 however it works on the simulator of ver 3.1.3 and 3.1.5 but it crahses on the simulaters of version less than 3.1.3 and also on 3.1.4.
If you are able to run the application on any of the device plz provide the version details of the respective device.

Hello Tenz,
We are using the ISQL extension .
but while running the sample aplication of ISQL we are getting crash on the Device anywhere on device LG8500 however it works on the simulator of ver 3.1.3 and 3.1.5 but it crahses on the simulaters of version less than 3.1.3 and also on 3.1.4.
If you are able to run the application on any of the device plz provide the version details of the respective device.