saifullah khan

saifullah khan

  • NA
  • 335
  • 301.8k

String was in a correct format

Jul 25 2011 6:34 AM
i have some error in code and i dont understand how to remove it.
double f,g;
string a,b;
con.Open();
cmd = new SqlCommand("select MAX (high) FROM DailyChange WHERE Symbol='" + Currency.SelectedValue.ToString() + "' AND Date='" + Label2.Text + "'", con);
a = cmd.ExecuteScalar().ToString();
f = Convert.ToDouble(a);
Response.Write(f);
con.Close();
con.Open();
cmd = new SqlCommand("select MAX (high) FROM DailyChange WHERE Symbol='" + Currency.SelectedValue.ToString() + "' AND Date='" + Label3.Text + "'", con);
b = cmd.ExecuteScalar().ToString();
 
g = Convert.ToDouble(b);
Response.Write(g);
con.Close();
It gives me the following error:
Input string was not in a correct format.
Line 81: g = Convert.ToDouble(b);

Answers (3)