Im not sure its possible but i want to use the basic structure of this try block all around my program (to help handle connection problems while retrieving a database), Is there a more efficient way (ie get the block in a class and just pass the fill command to it) that pasting this all over my already messy code?
Dim retry As Boolean = True
Dim AllOk As Boolean = False
While retry
Try
Tableadapter.fillbysomequery(dataset)
Catch exError As MySql.Data.MySqlClient.MySqlException
Select Case exError.Number
Case 1042
retry = CommonRoutines.ShowExceptionDialog(exError.Message, "No connection")
Case 0
retry = CommonRoutines.ShowExceptionDialog(exError.Message, "bad login")
End Select
End Try
End While
If AllOk Then
'Carry On with the setup stuff
End If
the commonroutines.showexptiondialog is a custom exception dialog that returns true or false depending on 'Retry' or Abort.
Several different fill queries in each of 10-15 would just make copying this around the place an absolute mess.