Error Handeling

adriaan

Member
Joined
Feb 28, 2005
Messages
13
Programming Experience
5-10
Error Handeling [RESOLVED]

Hi there,

I am trying to find the best way of retrying an operation after I have handled an error; currently i am doing it like this:

VB.NET:
 Try 
Retry:
	customers = DataAccess.LoadCustomers
Catch sqlEx as SqlException
	If sqlExl.Number = 1111 Then
		GoTo Retry
	Else
		Msgbox("Can't go on!")
	End If
End Try

my question is, is there better ways in doing this, because some people say that using GoTo is not good practice.

Thanks,
 
Last edited:
Especialy in .NET.... Goto is one of the last bastions from the good o'l (arguably) days of BASIC.

At any rate.... this might work for you:
VB.NET:
Dim LoopFlag As Boolean = True

Do While LoopFlag
 Try 
	customers = DataAccess.LoadCustomers
        LoopFlag = False
Catch sqlEx as SqlException
	If sqlExl.Number = 1111 Then
		'Error handling here
	Else
		Msgbox("Can't go on!")
	End If
End Try
Loop

Tg
 
Back
Top