Having disconnections with SQL Server using a wireless connection with NET 2.0

  • Thread starter Thread starter Josep
  • Start date Start date
J

Josep

Hello,

I've an aplication written in C# (NET Framework 2, not Compact) that
connects to SQL Server using a wireless connection with
System.Data.SqlClient, connecting to SQL Server using TCP/IP protocol.

I've small disconnections all the time. Doing a "ping -t SERVER" I lost
10% of the pings, but never more than two together.

The problem is that when I get disconnected the application gets frozen
(20 seconds aprox.). Is there a way to keep it going, because the
disconnections are so small. I don't know if SqlClient is aware of this
disconnections or if I should use another way to connect to SQL Server.

I'm new to wireless applications and I'm quite lost. I would be pleased
if someone helps me.


Thank you in advance,

Josep
 
Hello Josep,
I've an aplication written in C# (NET Framework 2, not Compact) that
connects to SQL Server using a wireless connection with
System.Data.SqlClient, connecting to SQL Server using TCP/IP protocol.
I've small disconnections all the time.

If you are having network disconnections below the TCP/IP level (such as not
good enough signal to the closes wireless access point), there isn't much
you can do programmatically to improve the situation. Is this the a single
computer installation, or are you using your application on multiple
computers? If multiple, do you experience connection errors in the other
computers as well?

I would first concentrate in eliminating the physical connection problems.
For example, try realigning the antennas of the wireless router. Or, if your
application is critical, purchase another wireless router/repeater, or
switch to a wired connection.

From your application you could try to automatically retry your database
operations if a network error occurs. For example, I once has a similar
situation, and I solved the issue by trying each operation up to three times
if it failed because of network connections. This isn't a nice solution, but
oftentimes gives you additional time to solve the issue once you find the
root cause.

Hope this helps, and Merry Christmas!

--
Regards,

Jani Järvinen
C# MVP
Vantaa, Finland
(e-mail address removed)
 
First of all, thank you sloan and Jani for replying.

After some tests, I've seen that the problem is with the Tablet PCs
we're using, that have an awful wireless card and they loose 20% of
packets (doing a ping) when you walk with the tablet PC.

But modifying all the application to make it support disconnected
connections is too costly and it adds much more complexity to the
application. And in fact there shouldn't be never disconnections for
long periods of time. Just these micro-disconnections I've told you,
because the zone of work is very well limited.


From your application you could try to automatically retry your
database operations if a network error occurs. For example, I once
has a similar situation, and I solved the issue by trying each
operation up to three times if it failed because of network
connections. This isn't a nice solution, but oftentimes gives you
additional time to solve the issue once you find the root cause.

Jani, when I connect to the database and there's no connection the
TabletPC gets frozen for 20 seconds, so to solve it I do a ping before
to be sure that there's connection with the server (I know that's not a
good solution but I couldn't find another way). But when it connects it
can loose the connection when there's a transaction so then gets
frozen. If the application could get the control again (without waiting
20 seconds) I would retry the operation as you said, without any doubt.

How did you do this without getting the application frozen? Are you
using SqlClient class or another one?


Hope this helps, and Merry Christmas!

Merry Xmas and Happy New 2009 !! :-)
 
Josep,

To prevent the application freezing when performing any operations, you need
to make sure that all operations that can perform database calls are
executed in a background thread. This will allow your main thread servicing
your UI to continue doing so. Of course, this may require making drastic
changes to the UI and design of the application. One of the main things you
want to look at is what should the UI do while the background thread is
processing the request. Should it just pop up a "working" window disabling
all user activity possibly with a "cancel" option that would kill the
background thread.
 
Thank you Dan.

For all the posts that have replied, I see there's no easy answer in
that problem. Then I could have this posibilities (sorted from easiest
to more difficult):
- Re-try it in the same thread (frozen problems).
- Have a background thread separating UI from database and process
code.
- Implement it with SQL Server Compact Edition and ADO.NET 3.5 Sync
Services.

I'll have a chat with my customer to see where we go to...



Thanks again!

Josep.



Dan said:
Josep,

To prevent the application freezing when performing any operations,
you need to make sure that all operations that can perform database
calls are executed in a background thread. This will allow your main
thread servicing your UI to continue doing so. Of course, this may
require making drastic changes to the UI and design of the
application. One of the main things you want to look at is what
should the UI do while the background thread is processing the
request. Should it just pop up a "working" window disabling all user
activity possibly with a "cancel" option that would kill the
background thread.



--
 
Back
Top