Hi
I used below code for inserting data into database
int Measure = Convert.ToInt32(this.txtMesure.Text.Trim());
if (Measure < 50 && Measure > 10)
{
_cmd.Parameters.AddWithValue("@Measure", "less than 50");
}
else
{
if (Measure < 100 && Measure > 50)
{
_cmd.Parameters.AddWithValue("@Measure", "morethan50");
}
}
it worked correctly but if I don't enter any data in txtmeasure it make below error
Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a correct format.
Source Error:
Line 843: //if (txtMesure.Text.Trim() != " " && txtMesure.Text.Trim() != null)
Line 844: //{
Line 845: int measure = Convert.ToInt32(this.txtMesure.Text.Trim());
Line 846:
Line 847: if (measure < 50 && measure > 10)
|
why this happen
I want if I don't enter any data in txtmeasure it doesn't enter anything in databse but above error happen
Best Regards
Neda