Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wireless being disconnected - detection

Status
Not open for further replies.

robert201

Programmer
Jul 18, 2007
80
0
0
TH
Hello,

I am doing development for a windows mobile device using Visual Basic 2005.

The customer want to be able to download the data from the main database and be able to work off-line.

So I have decided that all the data that is download will be written to a xml file that can be read by a dataset. Also use the dataset to write changes.

When the user goes online the changes they have made to the off-line xml file will need to update the SQL database, I will use the getChanges of the dataset to sync with the central database (SQL Server 2005)

However, the user will be using a wireless and I will need a condition in my code that will detect if the wireless gets disconnected so that they can use the off-line data in the xml file that can be read in by the dataset.

I am not sure how I would detect the wireless being disconnected, as this will disconnect from the sql server database?

Any advice would be most helpfull,

Many thanks,

Steve

 
2 options.

1) Try to connect to the database, if you fail, assume you are off line, if you succeed, assume you are online.

2) Use WMI to monitor the laptop's network connections.

I'm thinking 1) will be easier and faster to code.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Normally the mobile device will have an SDK that allows you to check for an active network connection.
 
Use Rick's Option #1. All you care about is trying to access the SQL DB anyway. While zarkon4's answer of using the SDK is correct, it also locks you into just that one device and when the customer decides to use a different one then you would have to revisit your code to use a new SDK. Even if you use the SDK, then will still have to run the check to see if the database is available... like I said... it's all you care about anyway.

Also, make sure you are not always trying to connect to the SQL DB on every user action... trying to connect to something that isn't there and then throwing an Exception is very time consuming -- Especially on a 400 Mhz ARM Processor. Another thing to think about is that writing to the Flash Memory is very slow, so do as little writing as possible. Another good hint... if you are using a lot of data "offline", make sure you and your customers have 128 Mb RAM Devices or your code will start throwing random (and very frustrating/misleading) exceptions as it runs out of memory.


Senior Software Developer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top