I am updating a quantity in my cart, but it is throwing a Sequence has no elements\' exception.
And I don\'t know what that even means. At first I thought that maybe
Part of the answer to 'handle' the 'Sequence has no elements' Exception in VB is to test for empty
If Not (myMap Is Nothing) Then
' execute code
End if
Where MyMap is the sequence queried returning empty/null. FYI
I had the same issue, i realized i had deleted the default image that was in the folder just update the media missing, on the specific file
First()
is causing this if your select returns 0 rows. You either have to catch that exception, or use FirstOrDefault()
which will return null in case of no elements.
The value is null, you have to check why... (in addition to the implementation of the solutions proposed here)
Check the hardware Connections.
You are using linq's First() method, which as per the documentation throws an InvalidOperationException if you are calling it on an empty collection.
If you expect the result of your query to be empty sometimes, you likely want to use FirstOrDefault(), which will return null if the collection is empty, instead of throwing an exception.
Instead of .First()
change it to .FirstOrDefault()