Pls send me Example code DataBase | developer.brewmp.com Pls send me Example code DataBase | developer.brewmp.com

Developer

Pls send me Example code DataBase

Forums:

Hello Friend Can any one PLease tell me how to use DataBase in Brew

any one can send me example code for database in brew ......pls do it hurry...

any one can send me example code for database in brew ......pls do it hurry...

hey check out the below code.... declare variables accordingly..
static void Displayfun( first * pMe,int rid)
{
AECHAR szBuff1[30];
char szTempBuf[50];
AEERect rc1;
int nofrec=0;
pMe->noflines =0;
MEMSET(szTempBuf,0,50);
rc1.x=10;
rc1.y=10;
rc1.dx=50;
rc1.dy=50;
pMe->m_ref=5;
if (pMe->pIDBMgr == NULL)
ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_DBMGR, (void **)&pMe->pIDBMgr);
pMe->pIDatabase = IDBMGR_OpenDatabase (pMe->pIDBMgr, "db1", TRUE);
IDISPLAY_ClearScreen(pMe->a.m_pIDisplay);
IDATABASE_Reset (pMe->pIDatabase);
pMe->pIDBRec2 = IDATABASE_GetRecordByID(pMe->pIDatabase, rid);
pMe->fieldType = IDBRECORD_NextField (pMe->pIDBRec2, &pMe->fieldName, &pMe->fieldLen);
pMe->data = IDBRECORD_GetField (pMe->pIDBRec2, &pMe->fieldName, &pMe->fieldType, &pMe->fieldLen);
if (pMe->data != NULL)
{
DBGPRINTF("DATA");
pMe->m_ref = 5;
//Convert Wide Char to ASCII char
WSTR_TO_STR(pMe->data,pMe->szBuf,50);
//Format the output data & store it in temp buff,that will pass to DisplayOutput()
SPRINTF (szTempBuf, " Name : %s", (char *)pMe->szBuf);
DisplayOutput(pMe,pMe->noflines++, szTempBuf);
}
pMe->fieldType = IDBRECORD_NextField (pMe->pIDBRec2, &pMe->fieldName, &pMe->fieldLen);
pMe->data = IDBRECORD_GetField (pMe->pIDBRec2, &pMe->fieldName, &pMe->fieldType, &pMe->fieldLen);
if (pMe->data != NULL)
{
WSTR_TO_STR(pMe->data,pMe->szBuf,50);
SPRINTF (szTempBuf, " Age : %s", (char *)pMe->szBuf);
DisplayOutput(pMe,pMe->noflines++, szTempBuf);
}
pMe->fieldType = IDBRECORD_NextField (pMe->pIDBRec2, &pMe->fieldName, &pMe->fieldLen);
pMe->data = IDBRECORD_GetField (pMe->pIDBRec2, &pMe->fieldName, &pMe->fieldType, &pMe->fieldLen);
if (pMe->data != NULL)
{
WSTR_TO_STR(pMe->data,pMe->szBuf,50);
SPRINTF (szTempBuf, " Location %s", (char *)pMe->szBuf);
DisplayOutput(pMe,pMe->noflines++, szTempBuf);
}
if(NULL==pMe->m_pSKeyMenu)
{
if(ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SOFTKEYCTL,(void **)&pMe->m_pSKeyMenu)!=SUCCESS)
return;
}
//if(ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SOFTKEYCTL,(void **)&pMe->m_pSKeyMenu ) == SUCCESS)
{
IMENUCTL_GetRect(pMe->m_pSKeyMenu,&rc1);
IMENUCTL_SetRect(pMe->m_pSKeyMenu,&rc1);
IMENUCTL_AddItem(pMe->m_pSKeyMenu,FIRST_RES_FILE,IDS_STRING10,10,NULL,0);
IMENUCTL_Redraw(pMe->m_pSKeyMenu);
}
IDBRECORD_Release(pMe->pIDBRec2);
pMe->pIDBRec2=NULL;
IDATABASE_Release (pMe->pIDatabase);
pMe->pIDatabase=NULL;
IDBMGR_Release (pMe->pIDBMgr);
pMe->pIDBMgr=NULL;

hey check out the below code.... declare variables accordingly..
static void Displayfun( first * pMe,int rid)
{
AECHAR szBuff1[30];
char szTempBuf[50];
AEERect rc1;
int nofrec=0;
pMe->noflines =0;
MEMSET(szTempBuf,0,50);
rc1.x=10;
rc1.y=10;
rc1.dx=50;
rc1.dy=50;
pMe->m_ref=5;
if (pMe->pIDBMgr == NULL)
ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_DBMGR, (void **)&pMe->pIDBMgr);
pMe->pIDatabase = IDBMGR_OpenDatabase (pMe->pIDBMgr, "db1", TRUE);
IDISPLAY_ClearScreen(pMe->a.m_pIDisplay);
IDATABASE_Reset (pMe->pIDatabase);
pMe->pIDBRec2 = IDATABASE_GetRecordByID(pMe->pIDatabase, rid);
pMe->fieldType = IDBRECORD_NextField (pMe->pIDBRec2, &pMe->fieldName, &pMe->fieldLen);
pMe->data = IDBRECORD_GetField (pMe->pIDBRec2, &pMe->fieldName, &pMe->fieldType, &pMe->fieldLen);
if (pMe->data != NULL)
{
DBGPRINTF("DATA");
pMe->m_ref = 5;
//Convert Wide Char to ASCII char
WSTR_TO_STR(pMe->data,pMe->szBuf,50);
//Format the output data & store it in temp buff,that will pass to DisplayOutput()
SPRINTF (szTempBuf, " Name : %s", (char *)pMe->szBuf);
DisplayOutput(pMe,pMe->noflines++, szTempBuf);
}
pMe->fieldType = IDBRECORD_NextField (pMe->pIDBRec2, &pMe->fieldName, &pMe->fieldLen);
pMe->data = IDBRECORD_GetField (pMe->pIDBRec2, &pMe->fieldName, &pMe->fieldType, &pMe->fieldLen);
if (pMe->data != NULL)
{
WSTR_TO_STR(pMe->data,pMe->szBuf,50);
SPRINTF (szTempBuf, " Age : %s", (char *)pMe->szBuf);
DisplayOutput(pMe,pMe->noflines++, szTempBuf);
}
pMe->fieldType = IDBRECORD_NextField (pMe->pIDBRec2, &pMe->fieldName, &pMe->fieldLen);
pMe->data = IDBRECORD_GetField (pMe->pIDBRec2, &pMe->fieldName, &pMe->fieldType, &pMe->fieldLen);
if (pMe->data != NULL)
{
WSTR_TO_STR(pMe->data,pMe->szBuf,50);
SPRINTF (szTempBuf, " Location %s", (char *)pMe->szBuf);
DisplayOutput(pMe,pMe->noflines++, szTempBuf);
}
if(NULL==pMe->m_pSKeyMenu)
{
if(ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SOFTKEYCTL,(void **)&pMe->m_pSKeyMenu)!=SUCCESS)
return;
}
//if(ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SOFTKEYCTL,(void **)&pMe->m_pSKeyMenu ) == SUCCESS)
{
IMENUCTL_GetRect(pMe->m_pSKeyMenu,&rc1);
IMENUCTL_SetRect(pMe->m_pSKeyMenu,&rc1);
IMENUCTL_AddItem(pMe->m_pSKeyMenu,FIRST_RES_FILE,IDS_STRING10,10,NULL,0);
IMENUCTL_Redraw(pMe->m_pSKeyMenu);
}
IDBRECORD_Release(pMe->pIDBRec2);
pMe->pIDBRec2=NULL;
IDATABASE_Release (pMe->pIDatabase);
pMe->pIDatabase=NULL;
IDBMGR_Release (pMe->pIDBMgr);
pMe->pIDBMgr=NULL;

search in BREW SDK example folder you will get it

search in BREW SDK example folder you will get it

hi ,
in API IDATABASE_CreateRecord what is second field AEEDBField??? if my application having 4 textfireld and one menu choice how could i create it

hi ,
in API IDATABASE_CreateRecord what is second field AEEDBField??? if my application having 4 textfireld and one menu choice how could i create it

U hav to first create a menuctl usin menu interface and create four text boxes usin ITExt.... menu creation is diff from database...

U hav to first create a menuctl usin menu interface and create four text boxes usin ITExt.... menu creation is diff from database...

hi shiny ,
actualy i had created , form with 4 text field and amd one choice menu.. i am able to push its contents in to file .. now i want to store it on to the database
for it whwt i have to do. i had done with
if((ISHELL_CreateInstance(pMe->a.m_pIShell,AEECLSID_DBMGR,(void **)&pMe->m_pIDBMgr))==SUCCESS)
{
pMe->m_pIDataBase=IDBMGR_OpenDatabase(pMe->m_pIDBMgr,"database.txt",TRUE);
if(pMe->m_pIDataBase!=NULL)
{
pMe->m_pIDBRecord=IDATABASE_CreateRecord(pMe->m_pIDataBase, AEEDBField * pDBFields,FIELD_NUM);
}
}
and i am not geting what actualy is AEEDBField *

hi shiny ,
actualy i had created , form with 4 text field and amd one choice menu.. i am able to push its contents in to file .. now i want to store it on to the database
for it whwt i have to do. i had done with
if((ISHELL_CreateInstance(pMe->a.m_pIShell,AEECLSID_DBMGR,(void **)&pMe->m_pIDBMgr))==SUCCESS)
{
pMe->m_pIDataBase=IDBMGR_OpenDatabase(pMe->m_pIDBMgr,"database.txt",TRUE);
if(pMe->m_pIDataBase!=NULL)
{
pMe->m_pIDBRecord=IDATABASE_CreateRecord(pMe->m_pIDataBase, AEEDBField * pDBFields,FIELD_NUM);
}
}
and i am not geting what actualy is AEEDBField *

To create a database we need
void ToCreateDataBaseand WriteaRecord(pMe)
{
IDBMgr * pIDBMgr;
IDatabase * pIDatabase ;
IDBRecord * pIDBRecord ;
AEEDBField dbField[1];
char str[30] = "BREW DATABASE";
//Fill the fields with the data,type,length etc.
dbField[0].fName = AEEDBFIELD_TEXT ;
dbField[0].fType = AEEDB_FT_STRING;
dbField[0].pBuffer = (void *) str;
dbField[0].wDataLen = STRLEN (str);
if(SUCCESS != ISHELL_CreateInstance(pMe->pIShell, AEECLSID_DBMGR, (void **)&pIDBMgr))
return;
if( (pIDatabase = IDBMGR_OpenDatabase (pIDBMgr, "db", TRUE)) == NULL)
return ;
if( (pIDBRecord = IDATABASE_CreateRecord (pIDatabase, dbField, 1)) == NULL )
return ;
IDBRECORD_Release (pIDBRecord);
IDATABASE_Release (pIDatabase);
IDBMGR_Release(pIDBMGR);

void ToReadfromtheDataBase(pMe)
{
IDBMgr * pIDBMgr;
IDatabase * pIDatabase ;
IDBRecord * pIDBRecord ;
AEEDBFieldType fieldType; // stores field type
AEEDBFieldName fieldName; // stores field name
uint16 fieldLen;
char str[30] = NULL;
if(SUCCESS != ISHELL_CreateInstance(pMe->pIShell, AEECLSID_DBMGR, (void **)&pIDBMgr))
return;
if( (pIDatabase = IDBMGR_OpenDatabase (pIDBMgr, "db", FALSE)) == NULL)
return;
IDATABASE_Reset (pIDatabase);
pIDBRec = IDATABASE_GetNextRecord (pIDatabase);
if (pIDBRec == NULL)
return;
fieldType = IDBRECORD_NextField (pIDBRec, &fieldName, &fieldLen);
data = IDBRECORD_GetField (pIDBRec, &fieldName, &fieldType, &fieldLen);
STRCPY(str,(char *)data);
DBGPRINTF("%s",str);

To create a database we need
void ToCreateDataBaseand WriteaRecord(pMe)
{
IDBMgr * pIDBMgr;
IDatabase * pIDatabase ;
IDBRecord * pIDBRecord ;
AEEDBField dbField[1];
char str[30] = "BREW DATABASE";
//Fill the fields with the data,type,length etc.
dbField[0].fName = AEEDBFIELD_TEXT ;
dbField[0].fType = AEEDB_FT_STRING;
dbField[0].pBuffer = (void *) str;
dbField[0].wDataLen = STRLEN (str);
if(SUCCESS != ISHELL_CreateInstance(pMe->pIShell, AEECLSID_DBMGR, (void **)&pIDBMgr))
return;
if( (pIDatabase = IDBMGR_OpenDatabase (pIDBMgr, "db", TRUE)) == NULL)
return ;
if( (pIDBRecord = IDATABASE_CreateRecord (pIDatabase, dbField, 1)) == NULL )
return ;
IDBRECORD_Release (pIDBRecord);
IDATABASE_Release (pIDatabase);
IDBMGR_Release(pIDBMGR);

void ToReadfromtheDataBase(pMe)
{
IDBMgr * pIDBMgr;
IDatabase * pIDatabase ;
IDBRecord * pIDBRecord ;
AEEDBFieldType fieldType; // stores field type
AEEDBFieldName fieldName; // stores field name
uint16 fieldLen;
char str[30] = NULL;
if(SUCCESS != ISHELL_CreateInstance(pMe->pIShell, AEECLSID_DBMGR, (void **)&pIDBMgr))
return;
if( (pIDatabase = IDBMGR_OpenDatabase (pIDBMgr, "db", FALSE)) == NULL)
return;
IDATABASE_Reset (pIDatabase);
pIDBRec = IDATABASE_GetNextRecord (pIDatabase);
if (pIDBRec == NULL)
return;
fieldType = IDBRECORD_NextField (pIDBRec, &fieldName, &fieldLen);
data = IDBRECORD_GetField (pIDBRec, &fieldName, &fieldType, &fieldLen);
STRCPY(str,(char *)data);
DBGPRINTF("%s",str);