Hi all. I have a For loop that processes a list of tasks inside the Try and Catch scope. Whenever there's an error/exception occurs in the Try scope, the error can be traced in the Catch scope. However, I wanted to compile a list of errors to be shown to the user and continue performing the next tasks. How do i do so? For example if i wanted to delete a list of records in the database:
How do i return from the Catch scope to the For loop? As i know whenever an error occurs it will jump to the Catch scope and execute whatever statements there and proceeds to Finally. Thanks in advance.Code:Dim cmDelete As New SqlCommand Dim i As Integer Try If cnDatabase.State = ConnectionState.Closed Then cnDatabase.Open() End If cmDelete.Connection = cnDatabase cmDelete.CommandText = "DELETE FROM Users WHERE ID=@ID" cmDelete.Parameters.Add("@ID", SqlDbType.Int) For i = 0 To 10 cmDelete.Parameters("@ID").Value = i cmDelete.ExecuteNonQuery() Next Catch ex As Exception 'Error goes here Finally cnDatabase.Close() End Try




Reply With Quote