Tutorials to .com

Tutorials to .com » Os » Mobile » Windows Mobile to use its own database WINCE

Windows Mobile to use its own database WINCE

Print View , by: iSee ,Total views: 29 ,Word Count: 2009 ,Date: Mon, 15 Jun 2009 Time: 8:46 PM

Through the database, can easily store and retrieve data, greatly enhancing efficiency. In Windows CE. NET 4.2, the bringing of a database, we can refer to specific pages MSDN on: Microsoft Windows CE. NET 4.2 database Reference. Because it only supports up to four kinds of sort index, the database for a smaller amount of data storage, data structure is relatively simple situation. It supports data types, including 2 / 4 bytes are / unsigned integer, date, time, Unicode strings, CEBLOB, Boolean, and 8-byte signed value.

The main operation of the database include the following:

:BOOL CeMountDBVol( PCEGUID pceguid, LPWSTR lpszDBVol,DWORD dwFlags);


:BOOL CeUnmountDBVol(PCEGUID pceguid);

:CEOID CeCreateDatabaseEx( PCEGUID pceguid, CEDBASEINFO *lpCEDBInfo);

: HANDLE CeOpenDatabaseEx( PCEGUID pceguid, PCEOID poid,LPWSTR lpszName,

CEPROPID propid, DWORD dwFlags,CENOTIFYREQUEST *pReq);

: CEOID CeWriteRecordProps(HANDLE hDbase, CEOID oidRecord,

WORD cPropID, CEPROPVAL *rgPropVal),





: CEOID CeReadRecordPropsEx( HANDLE hDbase, DWORD dwFlags,LPWORD lpcPropID,

CEPROPID *rgPropID, LPBYTE *lplpBuffer,LPDWORD lpcbBuffer, HANDLE hHeap);

:BOOL CeDeleteRecord(HANDLE hDatabase, CEOID oidRecord);

:CEOID CeSeekDatabaseEx(HANDLE hDatabase,DWORD dwSeekType,

DWORD dwValue, WORD wNumVals, LPDWORD lpdwIndex);
:BOOL CeMountDBVol( PCEGUID pceguid, LPWSTR lpszDBVol,DWORD dwFlags);


:BOOL CeUnmountDBVol(PCEGUID pceguid);

:CEOID CeCreateDatabaseEx( PCEGUID pceguid, CEDBASEINFO *lpCEDBInfo);

: HANDLE CeOpenDatabaseEx( PCEGUID pceguid, PCEOID poid,LPWSTR lpszName,

CEPROPID propid, DWORD dwFlags,CENOTIFYREQUEST *pReq);

: CEOID CeWriteRecordProps(HANDLE hDbase, CEOID oidRecord,

WORD cPropID, CEPROPVAL *rgPropVal),





: CEOID CeReadRecordPropsEx( HANDLE hDbase, DWORD dwFlags,LPWORD lpcPropID,

CEPROPID *rgPropID, LPBYTE *lplpBuffer,LPDWORD lpcbBuffer, HANDLE hHeap);

:BOOL CeDeleteRecord(HANDLE hDatabase, CEOID oidRecord);

:CEOID CeSeekDatabaseEx(HANDLE hDatabase,DWORD dwSeekType,

DWORD dwValue, WORD wNumVals, LPDWORD lpdwIndex);
:BOOL CeMountDBVol( PCEGUID pceguid, LPWSTR lpszDBVol,DWORD dwFlags);


:BOOL CeUnmountDBVol(PCEGUID pceguid);

:CEOID CeCreateDatabaseEx( PCEGUID pceguid, CEDBASEINFO *lpCEDBInfo);

: HANDLE CeOpenDatabaseEx( PCEGUID pceguid, PCEOID poid,LPWSTR lpszName,

CEPROPID propid, DWORD dwFlags,CENOTIFYREQUEST *pReq);

: CEOID CeWriteRecordProps(HANDLE hDbase, CEOID oidRecord,

WORD cPropID, CEPROPVAL *rgPropVal),





: CEOID CeReadRecordPropsEx( HANDLE hDbase, DWORD dwFlags,LPWORD lpcPropID,

CEPROPID *rgPropID, LPBYTE *lplpBuffer,LPDWORD lpcbBuffer, HANDLE hHeap);

:BOOL CeDeleteRecord(HANDLE hDatabase, CEOID oidRecord);

:CEOID CeSeekDatabaseEx(HANDLE hDatabase,DWORD dwSeekType,

DWORD dwValue, WORD wNumVals, LPDWORD lpdwIndex);
:BOOL CeMountDBVol( PCEGUID pceguid, LPWSTR lpszDBVol,DWORD dwFlags);


:BOOL CeUnmountDBVol(PCEGUID pceguid);

:CEOID CeCreateDatabaseEx( PCEGUID pceguid, CEDBASEINFO *lpCEDBInfo);

: HANDLE CeOpenDatabaseEx( PCEGUID pceguid, PCEOID poid,LPWSTR lpszName,

CEPROPID propid, DWORD dwFlags,CENOTIFYREQUEST *pReq);

: CEOID CeWriteRecordProps(HANDLE hDbase, CEOID oidRecord,

WORD cPropID, CEPROPVAL *rgPropVal),





: CEOID CeReadRecordPropsEx( HANDLE hDbase, DWORD dwFlags,LPWORD lpcPropID,

CEPROPID *rgPropID, LPBYTE *lplpBuffer,LPDWORD lpcbBuffer, HANDLE hHeap);

:BOOL CeDeleteRecord(HANDLE hDatabase, CEOID oidRecord);

:CEOID CeSeekDatabaseEx(HANDLE hDatabase,DWORD dwSeekType,

DWORD dwValue, WORD wNumVals, LPDWORD lpdwIndex);
:BOOL CeMountDBVol( PCEGUID pceguid, LPWSTR lpszDBVol,DWORD dwFlags);


:BOOL CeUnmountDBVol(PCEGUID pceguid);

:CEOID CeCreateDatabaseEx( PCEGUID pceguid, CEDBASEINFO *lpCEDBInfo);

: HANDLE CeOpenDatabaseEx( PCEGUID pceguid, PCEOID poid,LPWSTR lpszName,

CEPROPID propid, DWORD dwFlags,CENOTIFYREQUEST *pReq);

: CEOID CeWriteRecordProps(HANDLE hDbase, CEOID oidRecord,

WORD cPropID, CEPROPVAL *rgPropVal),





: CEOID CeReadRecordPropsEx( HANDLE hDbase, DWORD dwFlags,LPWORD lpcPropID,

CEPROPID *rgPropID, LPBYTE *lplpBuffer,LPDWORD lpcbBuffer, HANDLE hHeap);

:BOOL CeDeleteRecord(HANDLE hDatabase, CEOID oidRecord);

:CEOID CeSeekDatabaseEx(HANDLE hDatabase,DWORD dwSeekType,

DWORD dwValue, WORD wNumVals, LPDWORD lpdwIndex);
:BOOL CeMountDBVol( PCEGUID pceguid, LPWSTR lpszDBVol,DWORD dwFlags);


:BOOL CeUnmountDBVol(PCEGUID pceguid);

:CEOID CeCreateDatabaseEx( PCEGUID pceguid, CEDBASEINFO *lpCEDBInfo);

: HANDLE CeOpenDatabaseEx( PCEGUID pceguid, PCEOID poid,LPWSTR lpszName,

CEPROPID propid, DWORD dwFlags,CENOTIFYREQUEST *pReq);

: CEOID CeWriteRecordProps(HANDLE hDbase, CEOID oidRecord,

WORD cPropID, CEPROPVAL *rgPropVal),





: CEOID CeReadRecordPropsEx( HANDLE hDbase, DWORD dwFlags,LPWORD lpcPropID,

CEPROPID *rgPropID, LPBYTE *lplpBuffer,LPDWORD lpcbBuffer, HANDLE hHeap);

:BOOL CeDeleteRecord(HANDLE hDatabase, CEOID oidRecord);

:CEOID CeSeekDatabaseEx(HANDLE hDatabase,DWORD dwSeekType,

DWORD dwValue, WORD wNumVals, LPDWORD lpdwIndex);
:BOOL CeMountDBVol( PCEGUID pceguid, LPWSTR lpszDBVol,DWORD dwFlags);


:BOOL CeUnmountDBVol(PCEGUID pceguid);

:CEOID CeCreateDatabaseEx( PCEGUID pceguid, CEDBASEINFO *lpCEDBInfo);

: HANDLE CeOpenDatabaseEx( PCEGUID pceguid, PCEOID poid,LPWSTR lpszName,

CEPROPID propid, DWORD dwFlags,CENOTIFYREQUEST *pReq);

: CEOID CeWriteRecordProps(HANDLE hDbase, CEOID oidRecord,

WORD cPropID, CEPROPVAL *rgPropVal),





: CEOID CeReadRecordPropsEx( HANDLE hDbase, DWORD dwFlags,LPWORD lpcPropID,

CEPROPID *rgPropID, LPBYTE *lplpBuffer,LPDWORD lpcbBuffer, HANDLE hHeap);

:BOOL CeDeleteRecord(HANDLE hDatabase, CEOID oidRecord);

:CEOID CeSeekDatabaseEx(HANDLE hDatabase,DWORD dwSeekType,

DWORD dwValue, WORD wNumVals, LPDWORD lpdwIndex);
:BOOL CeMountDBVol( PCEGUID pceguid, LPWSTR lpszDBVol,DWORD dwFlags);


:BOOL CeUnmountDBVol(PCEGUID pceguid);

:CEOID CeCreateDatabaseEx( PCEGUID pceguid, CEDBASEINFO *lpCEDBInfo);

: HANDLE CeOpenDatabaseEx( PCEGUID pceguid, PCEOID poid,LPWSTR lpszName,

CEPROPID propid, DWORD dwFlags,CENOTIFYREQUEST *pReq);

: CEOID CeWriteRecordProps(HANDLE hDbase, CEOID oidRecord,

WORD cPropID, CEPROPVAL *rgPropVal),





: CEOID CeReadRecordPropsEx( HANDLE hDbase, DWORD dwFlags,LPWORD lpcPropID,

CEPROPID *rgPropID, LPBYTE *lplpBuffer,LPDWORD lpcbBuffer, HANDLE hHeap);

:BOOL CeDeleteRecord(HANDLE hDatabase, CEOID oidRecord);

:CEOID CeSeekDatabaseEx(HANDLE hDatabase,DWORD dwSeekType,

DWORD dwValue, WORD wNumVals, LPDWORD lpdwIndex);

Use

1. First of all, the first dialog box in the main document (here we have created a dialog-based project), we have to declare some variables, used to store the database file name and database name; the definition of a database table structure; and Information Library field identification, we have to mix MAKELONG macro database field type and logo. Related code is as follows:

Code
//
const LPTSTR DBFILENAME = _T("\My Documents\Workerinfo.db");


//
const LPTSTR DBTABLENAME = _T("Worker");

//
typedef struct{

TCHARszID[10];//ID

TCHARszName[20]; //

TCHAR szWorkNum[10]; //

TCHAR szDepartment[20]; //

}REC_WORKER,*PREC_WORKER;

//ID
#define PID_NOMAKELONG(CEVT_LPWSTR,1)

//
#define PID_NAMEMAKELONG(CEVT_LPWSTR,2)

//
#define PID_WorkNumMAKELONG(CEVT_LPWSTR,3)

//
#define PID_DepartmentMAKELONG(CEVT_LPWSTR,4)
Code
//
const LPTSTR DBFILENAME = _T("\My Documents\Workerinfo.db");


//
const LPTSTR DBTABLENAME = _T("Worker");

//
typedef struct{

TCHARszID[10];//ID

TCHARszName[20]; //

TCHAR szWorkNum[10]; //

TCHAR szDepartment[20]; //

}REC_WORKER,*PREC_WORKER;

//ID
#define PID_NOMAKELONG(CEVT_LPWSTR,1)

//
#define PID_NAMEMAKELONG(CEVT_LPWSTR,2)

//
#define PID_WorkNumMAKELONG(CEVT_LPWSTR,3)

//
#define PID_DepartmentMAKELONG(CEVT_LPWSTR,4)
Code
//
const LPTSTR DBFILENAME = _T("\My Documents\Workerinfo.db");


//
const LPTSTR DBTABLENAME = _T("Worker");

//
typedef struct{

TCHARszID[10];//ID

TCHARszName[20]; //

TCHAR szWorkNum[10]; //

TCHAR szDepartment[20]; //

}REC_WORKER,*PREC_WORKER;

//ID
#define PID_NOMAKELONG(CEVT_LPWSTR,1)

//
#define PID_NAMEMAKELONG(CEVT_LPWSTR,2)

//
#define PID_WorkNumMAKELONG(CEVT_LPWSTR,3)

//
#define PID_DepartmentMAKELONG(CEVT_LPWSTR,4)
Code
//
const LPTSTR DBFILENAME = _T("\My Documents\Workerinfo.db");


//
const LPTSTR DBTABLENAME = _T("Worker");

//
typedef struct{

TCHARszID[10];//ID

TCHARszName[20]; //

TCHAR szWorkNum[10]; //

TCHAR szDepartment[20]; //

}REC_WORKER,*PREC_WORKER;

//ID
#define PID_NOMAKELONG(CEVT_LPWSTR,1)

//
#define PID_NAMEMAKELONG(CEVT_LPWSTR,2)

//
#define PID_WorkNumMAKELONG(CEVT_LPWSTR,3)

//
#define PID_DepartmentMAKELONG(CEVT_LPWSTR,4)
Code
//
const LPTSTR DBFILENAME = _T("\My Documents\Workerinfo.db");


//
const LPTSTR DBTABLENAME = _T("Worker");

//
typedef struct{

TCHARszID[10];//ID

TCHARszName[20]; //

TCHAR szWorkNum[10]; //

TCHAR szDepartment[20]; //

}REC_WORKER,*PREC_WORKER;

//ID
#define PID_NOMAKELONG(CEVT_LPWSTR,1)

//
#define PID_NAMEMAKELONG(CEVT_LPWSTR,2)

//
#define PID_WorkNumMAKELONG(CEVT_LPWSTR,3)

//
#define PID_DepartmentMAKELONG(CEVT_LPWSTR,4)
Code
//
const LPTSTR DBFILENAME = _T("\My Documents\Workerinfo.db");


//
const LPTSTR DBTABLENAME = _T("Worker");

//
typedef struct{

TCHARszID[10];//ID

TCHARszName[20]; //

TCHAR szWorkNum[10]; //

TCHAR szDepartment[20]; //

}REC_WORKER,*PREC_WORKER;

//ID
#define PID_NOMAKELONG(CEVT_LPWSTR,1)

//
#define PID_NAMEMAKELONG(CEVT_LPWSTR,2)

//
#define PID_WorkNumMAKELONG(CEVT_LPWSTR,3)

//
#define PID_DepartmentMAKELONG(CEVT_LPWSTR,4)
Code
//
const LPTSTR DBFILENAME = _T("\My Documents\Workerinfo.db");


//
const LPTSTR DBTABLENAME = _T("Worker");

//
typedef struct{

TCHARszID[10];//ID

TCHARszName[20]; //

TCHAR szWorkNum[10]; //

TCHAR szDepartment[20]; //

}REC_WORKER,*PREC_WORKER;

//ID
#define PID_NOMAKELONG(CEVT_LPWSTR,1)

//
#define PID_NAMEMAKELONG(CEVT_LPWSTR,2)

//
#define PID_WorkNumMAKELONG(CEVT_LPWSTR,3)

//
#define PID_DepartmentMAKELONG(CEVT_LPWSTR,4)
Code
//
const LPTSTR DBFILENAME = _T("\My Documents\Workerinfo.db");


//
const LPTSTR DBTABLENAME = _T("Worker");

//
typedef struct{

TCHARszID[10];//ID

TCHARszName[20]; //

TCHAR szWorkNum[10]; //

TCHAR szDepartment[20]; //

}REC_WORKER,*PREC_WORKER;

//ID
#define PID_NOMAKELONG(CEVT_LPWSTR,1)

//
#define PID_NAMEMAKELONG(CEVT_LPWSTR,2)

//
#define PID_WorkNumMAKELONG(CEVT_LPWSTR,3)

//
#define PID_DepartmentMAKELONG(CEVT_LPWSTR,4)

2. The main dialog box to add three private member variables used to store library files volume logo, databases and database objects handle logo. Code snippet is as follows:

private:

CEGUID m_ceGuid; / / store database file logo

HANDLE m_hDB; / / store the database handle

CEOID m_ceOid; / / store database objects signs

3. In the main dialog box volumes are given in assembling the database, uninstall the database volume to create the database, open the database, writing database, reading the database, shut down operation of the database and so on. Not listed here.

Examples of projects is a WM6 platform WINCE database applications based on the dialog box, run the effect as follows:

Windows <a href=mobile to use its own database WINCE" />

Picture not clear? Click here to view the image (larger).

Figure 1: process diagram

In addition, the equipment we can "My Documents" directory, find "Workerinfo.db" document, as we document in the first set up the path, as shown in Figure 2:

Windows Mobile to use its own database WINCE

Figure 2: The database file path


Mobile OS Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.