none
Operation Not Valid Due to Current State of Object RRS feed

  • Question

  • MyModelRec has data, including .MfgId = 2.  .Father received new value fine but .MfgId throws error.  
    newMfgId has value of 49.  Can't figure out why .MfgId cannot be changed.
    Dim MyModelRec = (From mi In EquipInvenDB.ModelInfos _
        Where mi.RecIdent = UpdateRec).First
    With MyModelRec
        .Father = NewDad
        Dim newMfgID = CInt(cbManufacturer.SelectedValue)
        .MfgID = newMfgID
    End With

    ebassador
    "Find it, fix it, move on."


    • Edited by ebassador Wednesday, September 28, 2011 8:49 PM
    Wednesday, September 28, 2011 8:47 PM

All replies

  • Hi,

    IEnumerable.First() throws an exception if the enumerable contains no elements. May be you should use FirstOrDefault() and check for null if there is not any element returned.

    Best regards,

    JA Reyes.


    Please remember to Vote & "Mark As Answer" if this post is helpful to you.
    Por favor, recuerda Votar y "Marcar como respuesta" si la solución de esta pregunta te ha sido útil.
    Thursday, September 29, 2011 10:33 AM
  • Got same results!  There is data being returned.  All fields in the list are updatable except MfgId.  It is not set for readonly either so I'm really confused by this.
    ebassador
    "Find it, fix it, move on."
    Thursday, September 29, 2011 5:35 PM
  • Hello,

    Could you please describe your error information more detailed? Run your application and copy the exact error information in your reply to help us analyze your question better.

    Thanks,


    Larcolais Gong[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, September 30, 2011 2:43 AM