Convert variable to integer

Discussion in 'ASP .Net' started by staeri, Oct 27, 2006.

  1. staeri

    staeri Guest

    I need to input a stored procedure parameter as an integer but the
    conversion doesn't work. I get the error message "Input string was not
    in a correct format." I'm using the following code:

    Dim intObjectID As Integer = Convert.ToInt32(row.Cells(0).Text)

    With myCommand
    ..Parameters.Add(New SqlParameter("@ObjectID", SqlDbType.Int))
    ..Parameters("@ObjectID").Value = intObjectID

    Can someone please help me?

    // S
     
    staeri, Oct 27, 2006
    #1
    1. Advertisements

  2. It looks like the text in that cell was not a valid integer. You can't
    convert a string that doesn't contain an integer into one.
     
    Marina Levit [MVP], Oct 27, 2006
    #2
    1. Advertisements

  3. staeri

    Norman Yuan Guest

    Are you absolutely sure the cell'e text (row.Cells(0).Text) is numeric?
     
    Norman Yuan, Oct 27, 2006
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.