Hello Sir,
Getting error in below code: Input string was not in a correct format.
SqlConnection con12 = new SqlConnection(ConfigurationManager.ConnectionStrings["abc"].ConnectionString);
String strQuery = "select Id,care_level from table1 where" +
" Id = @Id";
SqlCommand cmd12 = new SqlCommand();
cmd12.Parameters.AddWithValue("@Id", DropDownList1.SelectedItem.Value);
cmd12.CommandType = CommandType.Text;
cmd12.CommandText = strQuery;
cmd12.Connection = con12;
try
{
con12.Open();
SqlDataReader sdr12 = cmd12.ExecuteReader();
while (sdr12.Read())
{
txt_value.Text = sdr12[1].ToString();
hcp.Visible = true;
}
string query = "SELECT top 1 [Level 1],[Level 2],[Level 3],[Level 4],[Level 5] from table2 order by Id desc;";
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = query;
cmd.Connection = con;
try
{
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
if txt_value.Text == "Level 1")
{
TextBox2.Text = sdr[0].ToString();
}
if txt_value.Text == "Level 2")
{
TextBox2.Text = sdr[1].ToString();
}
if txt_value.Text == "Level 3")
{
TextBox2.Text = sdr[2].ToString();
}
if txt_value.Text == "Level 4")
{
TextBox2.Text = sdr[3].ToString();
}
if txt_value.Text == "Level 5")
{
TextBox2.Text = sdr[4].ToString();
}
}
}
catch(Exception)
{
throw ex;}
}
catch(Exception)
{
throw ex;}
Please help.
Thanks