Dear experts,

I cannot seek the DB after mounted and opened the DB, I
think it needed to set the sort order before seek but if
I set it, the DB cannot be opened, what's wrong in my
code?


Following is the extract of my code in eVC3.0:

//====================begin===============================
HANDLE g_hDB = 0; // Handle to database
CEOID g_oidDB = 0; // Object ID of the database
CEGUID g_guidDB; // Guid for database volume
DWORD dwIndex;
CEPROPVAL propSeek;

// Below is property for the sort order
const CEPROPID BookID = MAKELONG (CEVT_LPWSTR, 1);

// I can mount the .cdb successfully
CeMountDBVol(&g_guidDB, _T("\\test.cdb", OPEN_EXISTING);

// I can open the DB if no sort order
// but error to open if any sort order exist, why?
g_hDB = CeOpenDatabaseEx (&g_guidDB, &g_oidDB, _T("book"),
//BookID, //caused runtime error
if use "BookID", so I only can use the default '0' here:
0,
0, NULL);

//First seek to the start of the database, success for
offset value.
//The bookID in the first record should be "00001111"
CeSeekDatabase(g_hDB, CEDB_SEEK_BEGINNING, 0, &dwIndex);

//Seek the record with passed-in parameter
//search value below, just a sample and this record does
exist
propSeek.propid = BookID;
propSeek.val.lpwstr = _T("00005555");

//anyway, string value always cannot be seek, only offset
success
g_oidDB = CeSeekDatabase(g_hDB, CEDB_SEEK_VALUEGREATER,
(DWORD)&propSeek, &dwIndex);

//then read the record, it done well
CEOID ceoidRec;
DWORD dwBuf;
CEPROPVAL *props = NULL;
unsigned short lProps;

ceoidRec = CeReadRecordPropsEx(hDB, CEDB_ALLOWREALLOC,
&lProps, NULL,
(LPBYTE*)&props, &dwBuf, NULL);

//try to display the result
MessageBox (hWnd, props[0].val.lpwstr , _T("Message"),
MB_OK);

//======================end===============================


What do you think the result?
Right! it's "00001111", that means the first record,
haven't seek?

I created the access ".mdb" file with sample records,
field is "BookID" with index that must be unique,
from "00001111" to "00009999". And then I copy it to my
iPAQ3970 (I've also try with iPAQ3950 as well as the
emulator with same result), it converted to "test.cdb"
(without synchronization).

I have try the VOConnection and VORecordset, it can seek
by SQL but very slow where my real database have 30
thousand records and besides the speed, very strange that
some records in the middle cannot be seek and read,
(about the 15000'th to 20000'th records), I don't know
whether it's memory problem but my iPAQ still have very
much main memory spaces.

How can I use the sort order and seek my record in API?
Thousand thanks!

Nick.

Re: How to OPEN and SEEK .cdb using API? by Chris

Chris
Tue Nov 11 08:26:40 CST 2003

The CEDB provider doesn't support Seek.

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net

"nicknick" <millennium_ii@hotmail.com> wrote in message
news:0baa01c3a83f$ea150d00$a301280a@phx.gbl...
> Dear experts,
>
> I cannot seek the DB after mounted and opened the DB, I
> think it needed to set the sort order before seek but if
> I set it, the DB cannot be opened, what's wrong in my
> code?
>
>
> Following is the extract of my code in eVC3.0:
>
> //====================begin===============================
> HANDLE g_hDB = 0; // Handle to database
> CEOID g_oidDB = 0; // Object ID of the database
> CEGUID g_guidDB; // Guid for database volume
> DWORD dwIndex;
> CEPROPVAL propSeek;
>
> // Below is property for the sort order
> const CEPROPID BookID = MAKELONG (CEVT_LPWSTR, 1);
>
> // I can mount the .cdb successfully
> CeMountDBVol(&g_guidDB, _T("\\test.cdb", OPEN_EXISTING);
>
> // I can open the DB if no sort order
> // but error to open if any sort order exist, why?
> g_hDB = CeOpenDatabaseEx (&g_guidDB, &g_oidDB, _T("book"),
> //BookID, //caused runtime error
> if use "BookID", so I only can use the default '0' here:
> 0,
> 0, NULL);
>
> //First seek to the start of the database, success for
> offset value.
> //The bookID in the first record should be "00001111"
> CeSeekDatabase(g_hDB, CEDB_SEEK_BEGINNING, 0, &dwIndex);
>
> //Seek the record with passed-in parameter
> //search value below, just a sample and this record does
> exist
> propSeek.propid = BookID;
> propSeek.val.lpwstr = _T("00005555");
>
> //anyway, string value always cannot be seek, only offset
> success
> g_oidDB = CeSeekDatabase(g_hDB, CEDB_SEEK_VALUEGREATER,
> (DWORD)&propSeek, &dwIndex);
>
> //then read the record, it done well
> CEOID ceoidRec;
> DWORD dwBuf;
> CEPROPVAL *props = NULL;
> unsigned short lProps;
>
> ceoidRec = CeReadRecordPropsEx(hDB, CEDB_ALLOWREALLOC,
> &lProps, NULL,
> (LPBYTE*)&props, &dwBuf, NULL);
>
> //try to display the result
> MessageBox (hWnd, props[0].val.lpwstr , _T("Message"),
> MB_OK);
>
> //======================end===============================
>
>
> What do you think the result?
> Right! it's "00001111", that means the first record,
> haven't seek?
>
> I created the access ".mdb" file with sample records,
> field is "BookID" with index that must be unique,
> from "00001111" to "00009999". And then I copy it to my
> iPAQ3970 (I've also try with iPAQ3950 as well as the
> emulator with same result), it converted to "test.cdb"
> (without synchronization).
>
> I have try the VOConnection and VORecordset, it can seek
> by SQL but very slow where my real database have 30
> thousand records and besides the speed, very strange that
> some records in the middle cannot be seek and read,
> (about the 15000'th to 20000'th records), I don't know
> whether it's memory problem but my iPAQ still have very
> much main memory spaces.
>
> How can I use the sort order and seek my record in API?
> Thousand thanks!
>
> Nick.



Re: How to OPEN and SEEK .cdb using API? by nicknick

nicknick
Wed Nov 12 20:30:19 CST 2003

No! it can be seeked if the .cdb is create and add record
within the pocketPC, but it goes wrong if I use a DB
converted from .mdb to .cdb

May be it should called "searching" instead of "seek"?


I also can "seek" the 3rd record if I use this API:

CeSeekDatabase(g_hDB, CEDB_SEEK_BEGINNING, 3,
&dwIndex);


but I cannot "seek" if I use string such as:

CeSeekDatabase(g_hDB, CEDB_SEEK_VALUEGREATER,
(DWORD)&propSeek, &dwIndex);


and idea? is it the problem of Activesync or the convert
process, something like that?



>-----Original Message-----
>The CEDB provider doesn't support Seek.
>
>--
>Chris Tacke, eMVP
>Co-Founder and Advisory Board Member
>www.OpenNETCF.org
>---
>Windows CE Product Manager
>Applied Data Systems
>www.applieddata.net
>
>"nicknick" <millennium_ii@hotmail.com> wrote in message
>news:0baa01c3a83f$ea150d00$a301280a@phx.gbl...
>> Dear experts,
>>
>> I cannot seek the DB after mounted and opened the DB, I
>> think it needed to set the sort order before seek but
if
>> I set it, the DB cannot be opened, what's wrong in my
>> code?