locked
Casting error RRS feed

  • Question

  • User-124714496 posted

    Hello all,

    I have a strange problem with a update from a gridview in ling2sql.

    When I make a new record everything goes well, if I use the same syntax for an update with commandbutton I get a casting error.

    Anyone a clue? The code is :

     

    newUrens.aantalUur = CDec(tburen.Text)

    newUrens.aantaluur50 = CDec(tb50.Text)

    newUrens.aantaluurNacht = 

    CDec(tbnacht.Text)

     

    The fields are al decimal

    Thanks,

     

    Peter

     

    Friday, November 13, 2009 6:04 PM

Answers

  • User1282917655 posted

    try this

     

    Dim str As String = "25.0"
    
    Dim value As Decimal
    
    If IsNumeric(str) Then
       value = CType(str, Decimal)
    
    Else
        value = 0D
    
    End If
    


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 15, 2009 7:46 AM

All replies

  • User1086899631 posted

    Hi,

    Try Decimal.Parse(textbox1.Text)


    Friday, November 13, 2009 10:39 PM
  • User-124714496 posted

    Hi ankit,

    Thank you for your reply, when I use decimal.parse I get a Formatexeption.

    And can you, just currious, tell me the difference with parse?

    Thanks,

     

    Peter 

    Saturday, November 14, 2009 2:52 AM
  • User1282917655 posted

    try this

     

    Dim str As String = "25.0"
    
    Dim value As Decimal
    
    If IsNumeric(str) Then
       value = CType(str, Decimal)
    
    Else
        value = 0D
    
    End If
    


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 15, 2009 7:46 AM
  • User-124714496 posted

    Hi Abdulla,

     

    Thanks for your reply, the casting error is gone. Thank you for that, de update won't work. But thats a other issue :)

     

    Thanks again,

     

    Peter

     

    Sunday, November 15, 2009 10:27 AM