Click here to Skip to main content
15,893,337 members
Articles / Programming Languages / C#

error input string is not correct format on line:int nActualQty = Convert.ToInt32(textBox5.Text.ToString());

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
18 Nov 2012CPOL 2K  
private void textBox5_TextChanged(object sender, EventArgs e){ objConn1.Open(); int nQty = 0; int nActualQty = Convert.ToInt32(textBox5.Text.ToString()); string sql3 = "select qty from dbo.RateMouldQuantity where ratechart= '" + comboBox5.SelectedValue.ToString() + "'";...

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
18 Nov 2012OriginalGriff
What it means is that the string in the TextBox is not a valid integer - it may contain a decimal point, or an alphabetic character.Try using TryParse instead:int nActualQty;if (!int.TryParse(textBox5.Text, out nActualQty)) { // Report problem to user - he typed wrong. ... ...

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions