Durga Velusamy

Durga Velusamy

  • NA
  • 318
  • 115.1k

please find the error

Apr 13 2015 1:58 AM
I have following code its shows an error please some one find what mistake I have done.
Error at 9th line as "Input string was not in a correct format".
 
private void button2_Click(object sender, EventArgs e)
  {
 
  int CustomerId=0;
  int i=0;  
  SqlConnection con = new SqlConnection(@"server=CSE-PC; integrated security=true; Database=Bas");
  con.Open();  
  SqlCommand com = new SqlCommand("select max(CustomerId) FROM DEVI", con);  
  CustomerId = int.Parse(com.ExecuteScalar().ToString());  
 /*Input string was not in a correct format.*/
  if (i>0)
  {
  CustomerId = CustomerId + 1;
   }
  else
  {
  CustomerId = 001;
  }
  comboBox1.Items.Add("CustomerId");
  i = i + 1;
  MessageBox.Show("IdCreated");
  con.Close();
  }

Answers (4)