My app was installed on a customer's network which was VERY unreliable... we had to retry a command's execution after a lost connection because the second time it usually passed through (we're talking SQL Server 2005 here).
Assumming you're using Transactions (if not then you should), here's my Commit Transaction wrapper which handles lost connections fairly well (could be optimized I guess... but its just a copy/paste from my code):
Public Shared Function SafeCommitRollback(ByVal Trans As SqlClient.SqlTransaction, Optional ByVal Action As TROperation = TROperation.Commit, Optional ByVal QuietMode As Boolean = False) As Boolean
SafeCommitRollback = False
Dim TryRollback As Boolean = False
Dim ConnLost As Boolean = False
Dim msgErr As String = ""
If Action = TROperation.Commit Then
Try
Trans.Commit()
SafeCommitRollback = True
Catch ex As SqlClient.SqlException When ex.Class = 20 OrElse (ex.Class = 11 And ex.Number = -2)
ConnLost = True
Catch ex As System.InvalidOperationException When ex.Source = "System.Data" 'AndAlso ex.Message.StartsWith("Timeout expired.")
ConnLost = True
Catch ex As Exception
TryRollback = True
msgErr &= clsErrorHandling.ParseException(ex, True)
End Try
If ConnLost Then
Try
Trans.Commit()
SafeCommitRollback = True
Catch ex2 As Exception
TryRollback = True
msgErr &= clsErrorHandling.ParseException(ex2, True)
End Try
End If
Else
TryRollback = True
End If
If TryRollback Then
Try
Trans.Rollback()
If Action = TROperation.Rollback Then SafeCommitRollback = True
Catch ex3 As Exception
msgErr &= clsErrorHandling.ParseException(ex3)
End Try
End If
If Not QuietMode AndAlso msgErr.Trim <> "" Then clsMessageBox.ShowError(msgErr)
End Function
I hope this helps...