3
Answers

How to compare two number ...

ancy chacko

ancy chacko

9y
621
1
Hi
  
   Error :

Specified cast is not valid.

protected void Button2_Click(object sender, EventArgs e)

    {

        MySqlDataAdapter da = new MySqlDataAdapter("select *  from leaveform ", cn);

        DataTable dt = new DataTable();


        DataSet ds = new DataSet();

        da.Fill(ds);

        foreach (DataRow dr in ds.Tables[0].Rows)

        {

            //Convert.ToInt32


            Double col1Value = (Double)dr["Leavebal"];

            Double col1Value2 = (Double)dr["Number"];

           // Label3.Text = col1Value.ToString();

            //Label1.Text = col1Value2.ToString();

            if (col1Value <= col1Value2 )

            {

                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert(' ...  ')", true);


            }

            else

            {



                string str3 = "insert into leaveform values('" + dplsttype.SelectedItem.Text + "','" + TextBox1.Text + "','" + Label4.Text + "','" + Label3.Text + "','" + txtfrom.Text + "', '" + dpleavefrom.SelectedItem.Text + "','" + txtto.Text + "','" + dpleaveto.SelectedItem.Text + "','" + Label1.Text + "','" + txtremark.Text + "')";

                MySqlCommand Cmd = new MySqlCommand(str3, cn);

                Cmd.ExecuteNonQuery();

                

            }

        }

        


    }


      
Answers (3)