Solved

C# Offline Mode

Posted on 2006-06-19
5
988 Views
Last Modified: 2008-02-26
Hello experts,

I am creating a distributed application which utliizes a central database to manage data.  I would like allow users to store some data offline so that, in the case that they are not connected to the internet or the SQL server is down, they are still able to view existing data and perform offline functions.

There are two problems I have with this implementation.

(1) How can I check whether the user is connected to the internet or not
(2) How can I check whether the SQL server is running (assuming the user is online)

Thanks,

-T
0
Comment
Question by:TLevin10
  • 3
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
dttri earned 250 total points
ID: 16935832
Greetings,
(1): You can check internet connection with this:
http://www.codeproject.com/cs/internet/internetconnection_status.asp
(2): To check the SQL Server is running or not, just connect to it (assume that your internet connection is OK) using a username and password and get the result back.

Hope this help
0
 

Author Comment

by:TLevin10
ID: 16936681
Hi dttri,

Thanks for the quick response.

(1) Checking Internet Connection - This is a very interesting approach and I will try it out.  Good information :)

(2) Checking SQL Server - Maybe I'm wrong, but this seems like a bit of a hack - I don't want to be constantly trying to connect to the SQL server in order to check its status, causing excess traffic.  Is there some sort of function to do this which is not a try/catch block I am executing repeatedly, or am I just responsible for wrapping all of my SQL queries in a try/catch and catching the SQL Excpetion?

Thanks
0
 
LVL 7

Expert Comment

by:dttri
ID: 16949032
Hi TLevin10,
For the second question, I think using the way I mentioned will cost bandwidth, but it's not a bad idea ;). You can use the reverse: get SQL Server let you know that it's running by constant sending your program some signal at specific interval. But this way will cost bandwidth also! I think most of the programs using one of the ways I suggest. The different is the time interval to check. The shorter time, the more correct your get but the more traffic also. Do you know Yahoo! Messenger? I use it everyday and I think it display the online status of users by constant checking connection with them. Because of the way it check online status, it's not perfect; for example, when someone get disconnected suddenly (eg, because of power problem) it still display their status as "online" although it's not.
0
 

Author Comment

by:TLevin10
ID: 16951538
Interesting... I will award the points, since it seems there are a variety of solutions to the problem...
0
 
LVL 7

Expert Comment

by:dttri
ID: 16952840
Thanks for the points TLevin10 :-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question