I am getting a FormatException error.
The error is coming up on the following line. The MaskedTextBox only allows numbers.Input string was not in a correct format
The code is as follows:Code:.Parameters.Add("@StoreNumber", SqlDbType.Int).Value = Int32.Parse(SearchStoreNumber.Text.Trim)
The parameter in the PROC is INT and the MSSQL column is also an INT.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
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.




Reply With Quote