ancy chacko

ancy chacko

  • NA
  • 71
  • 17.3k

inserting data into database

Feb 2 2015 5:08 AM
i am didnt get the correct output ....there is no error ....any one check my coding



MySqlDataAdapter da = new MySqlDataAdapter("select *  from leavefomm  where empcode = '" + TextBox1.Text + "'", cn);
        DataTable dt = new DataTable();

        DataSet ds = new DataSet();
        da.Fill(ds);
        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            //Convert.ToInt32
            Double col1Value = 0;
            Double col2Value = 0;

            if (!Convert.IsDBNull(dr["Leavebal"])) 
            {
                col1Value = (Double)dr["Leavebal"];
                Label3.Text = col1Value.ToString();
            }

            if (!Convert.IsDBNull(dr["Number"])) 
            {

                col2Value = (Double)dr["Number"];
                Label1.Text= col2Value.ToString();
            }

            if (col1Value <= col2Value)
            
            {
                

                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert(' ......  ')", true);
            }
            else
            {
                cn.Open();
                string str3 = "insert into leavefomm 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();
                cn.Close();
                



           }
        }

Answers (3)