Wednesday, March 28, 2012

Loosing database connection when device power-off (native oledb code)

Hi,

I experienced this problems on both Windows Mobile 2003 SE and Windows Mobile 5.0.

Its native development (c++, oledb, atl and mfc).

It's quite simple to reproduce...

1. open a database

2. open a rowset on table A (whatever, valid of course and with both IOpenRowset and ICommandText), read datas and close rowset

3. power off

4. power on

5. try step 2 with another table (failed on openrowset with error 0x80004005) or try table A (sometimes working because of cached memory, sometims failed on Read Datas).

6. being stuck ;-)

Our work-around was, in case we loose our connection (identified by error 0x80004005 on openrowset), we close it and re-open database... ugly for sure, but working.

What I'm looking now is to use some kind of "detection method" like what people in .Net develoment are using "if ConnectionState.Open <> ...) for reopening my database only on demand...

Thanks in advance for any hints,
Fabien.

Your application should detect device going standby, closing connection which should be reestablished upon power up.

You've already found similar solution, you might as well continue doing that instead of making your application power state aware.

Note: that usually happens if database is on removable storage card.

|||

Thanks for your answer.

You're right about the removable storage card (both using SD and CF on X50/X51).

Have you any hint how to detect device going stand by and how to detect power up ?

Is it normal notifications or should I implement an OleDB interface ?

Regards,

Thanks,
Fabien.

|||

This might be of help:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceddk5/html/wce50lrfrequestpowernotifications.asp

|||

Thanks a lot.

I'm just afraid that I've no other ways to go if I want to make my application Power aware ;-)

I had read those articles before.

In the meantime, my work-around seems to work so far, so I already won 10 days to implement the power features with no pressure.

I'm just sad that DBCONNECTION_STATUS is not implemented.

Again, thanks for your tips.

No comments:

Post a Comment