Results 1 to 4 of 4

Thread: [RESOLVED] Input string was not in a correct format

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Resolved [RESOLVED] Input string was not in a correct format

    I am getting a FormatException error.
    Input string was not in a correct format
    The error is coming up on the following line. The MaskedTextBox only allows numbers.
    Code:
    .Parameters.Add("@StoreNumber", SqlDbType.Int).Value = Int32.Parse(SearchStoreNumber.Text.Trim)
    The code is as follows:
    Code:
                        If Not SearchStoreNumber.Enabled = False Then
                            If Not SearchStoreNumber.Text <> vbNullString Then
                                .Parameters.Add("@StoreNumber", SqlDbType.Int).Value = Int32.Parse(SearchStoreNumber.Text.Trim)
                            Else
                                .Parameters.Add("@StoreNumber", SqlDbType.Int).Value = DBNull.Value
                            End If
                        Else
                            .Parameters.Add("@StoreNumber", SqlDbType.Int).Value = DBNull.Value
                        End If
    The parameter in the PROC is INT and the MSSQL column is also an INT.
    I am not sure what to do. I have tried so many things without success.
    This field is an optional field, but I do not get the error if the MaskedTextBox is not empty.
    If I select only the Date to/from with the store number blank, it should show entries within that date range, but the error always goes to the store number code as the issue.

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Input string was not in a correct format

    I am going to set some boolean flags and do it that way. maybe that will give me what i need.

  3. #3

  4. #4
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,518

    Re: [RESOLVED] Input string was not in a correct format

    but I do not get the error if the MaskedTextBox is not empty.
    what about something like, "If Not String.IsNullOrEmpty(SearchStoreNumber.Text) Then"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width