Hi Mike and Dave:
I sure appreciate your help! This is a very tricky problem for which I have tried everything I can think of. I'm game to rethink anything!
Let me digress a moment and give you the background setup.
There are several computers, besides my PDA and the 'server' in the network. All the computers are running windows xp and serve different members of my staff--and all of which are putting in information pertinent to their job. The PDA is an HP IPAQ running Windows CE Mobile, second edition.
The goal in all this is for the PDA to recieve data in real-time from the 'server' (itself a windows xp machine) and for the PDA to immediately update the 'server' via wireless 802.11b.
I purchased Visual CE to write the forms for the PDA and their sister product, mEnable, to transmit the data between the PDA and the 'Server'. On the server is a TSR version of mEnable which uses ODBC to read/write to the vfp tables. (The ODBC driver being supplied by Visual CE. mEnable does not seem to be able to read the database containers, so I don't think I can get it to see views.)
I have no access to the mEnable code--everything else I've written from the ground up--so all is changeable.
My basic starting scheme was to keep things as simple as possible. Therefore, initially I kept all the tables as unbuffered and free. Doing it this way led to some interesting problems.
Problem: Sending records from the PDA to the Server resulted in dropped records. However, sending records from the Server to the PDA is 100% accurate.
I.e., New or changed records on the PDA were not being picked up by VFP.
Now, according to tek support at Visual CE, this is 'not possible', but perhaps there was an 'indexing' problem on the shared file and the 'vfp not being a true database server' maybe in some way altering the file.
I guess it's possible. My testing showed that:
1. VFP is so fast that it can completely read/write/update all the computers on the network in under 0.03 seconds, and
2. VFP was accessing the files durring an mEnable session.
My conclusion is that mEnable is using a record locking scheme. Also, once mEnable has 'synced' it assumes that the recieving side of mEnable got the information. Hence, if vfp finished before mEnable finished sending the record, nobody on the server will have the record, even though the PDA has the correct version. i.e., it can not be resent without rewriting the entire record on the PDA and starting over.
I then rewrote the whole thing to use optimistic table buffering on the vfp side of the tables. I don't know how mEnable views the tables..
Mikes' idea of forcing mEnable to use a view maybe the way to go, but I don't think that will avoid the problem of a partially written record from the PDA and nor does mEnable use the database container--so I don't know how to convince it to use a view. The transmission time of the PDA is easily measured in seconds, and for either VFP or mEnable to recieve partial records is useless. Hence, I then tried the starting scheme of this thread of letting my server startup by using the files in unbuffered shared mode, then durring read/writes to the pda files, forcing them into exclusive mode.
Problem: After opening the files in shared mode, if mEnable is allowed to sync, VFP can no longer reopen (after closing them) in Exclusive mode for the read/writes.
Further testing, however, showed that even with mEnable running and syncing, if I completely exited VFP back to the windows desktop and immediately reentered VFP (making no other changes), those same files that vfp could not open exclusively could now be opened exclusivly--but doing this every time the table needs to be polled is dumn and impossible.
Hence, my conclusion, is that it is not mEnable but rather VFP (or me) that is having the problem. It's almost as if once vfp fails, it stops trying--and no amount of Use..Shared, followed by Use...Exclusive will work.
In my most recent reiteration, I'm again rewritting this thing by :
1. putting all the 'sync' tables into a database containter;
2. changing the cursors to optimistic table buffering,
and ;
3. read/writing to the base tables by way of a transaction.
My hope is that if mEnable is read/writing to the tables at the same time as the transaction, that the transaction will fail allowing the server to backup and wait for mEnable to finish before trying again. I have no idea if this will work. I'm trying to preserve whatever table indexs mEnable is using..i.e., avoid writing to the tables by vfp while mEnable is writing to the tables.
Buf if mEnable is using record locks and is much, much, much slower then VFP, could VFP still not be in and out of the table before mEnable is finished? I guess the question is, does a record lock by mEnable stop the transaction? And what would happen if both vfp and menable are adding a new record at the same time?
As far as I know, I have no way of detecting when mEnable is 'syncing' from the desktop.
Anyway, I hope I've given you'all the picture. Overall, its been a networking nightmare that shouldn't have been...
If this fails, I guess I'll move on to views, but I don't see how that avoids the basic problem of possibly corrupting mEnable's index (if there are any) while mEnable is syncing.
Thank you'all very very much for your time, patience, and ideas--I'm sure glad to hear from you. I promise not to be so long winded next time. This is very frustrating.
Sincerely,
Alan