Bharathi Raja

Bharathi Raja

  • NA
  • 1.1k
  • 54.5k

Error : Index was outside the bounds of the array.

Jul 26 2017 9:18 AM
connection.Open();
MySqlCommand cmd_tax = new MySqlCommand("select tax_cat from item_master where cat='1' limit 0,3",connection);
MySqlDataReader dread_tax = cmd_tax.ExecuteReader();
int x = 0;
sub_tot = Convert.ToDouble(textBox5.Text);
while (dread_tax.Read())
{
if (x == 0)
{
x = 1;
ser_tax = ((Convert.ToDouble(dread_tax.GetValue(1).ToString()) / 100) * sub_tot);
textBox10.Text = ser_tax.ToString();
}
else if (x == 1)
{
x = 2;
vat = ((Convert.ToDouble(dread_tax.GetValue(1).ToString()) / 100) * sub_tot);
textBox11.Text = vat.ToString();
}
else
{
sc = ((Convert.ToDouble(dread_tax.GetValue(1).ToString()) / 100) * sub_tot);
textBox15.Text = sc.ToString();
}
}
dread_tax.Close();
connection.Close();

Answers (5)