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.