[RESOLVED] Input string was not in a correct format
I am getting a FormatException error.
Quote:
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.
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.
Re: Input string was not in a correct format
I got it working using a boolean flag. Phew!
Re: [RESOLVED] Input string was not in a correct format
Quote:
but I do not get the error if the MaskedTextBox is not empty.
what about something like, "If Not String.IsNullOrEmpty(SearchStoreNumber.Text) Then"