im new with sql and c# and im having an error in executenonquery commandtex. i dont know where the error is. can you guys help me out here?
private void submitBtn_Click(object sender, EventArgs e)
{
con.Open();
string a = "Accept";
string b = "Reject";
string queryUpdate1 = "";
string queryUpdate2 = "";
int row = DGVLeaves.CurrentCell.RowIndex;
if (accptBtn.Checked)
{
if (type_rdonly.Text == "SL")
{
if (ifEmployeeExist(con, emptime_rdonly.Text))
{
queryUpdate1 = @"UPDATE [LEAVE_EMP] SET EMP_STATUS ='" + a + "'WHERE [EMP_TIME] ='" + emptime_rdonly.Text + "'";
}
queryUpdate2 = "UPDATE LEAVE_ADMIN SET L_SPENT_SL = (L_SPENT_SL + 1), L_REM_SL = (L_REM_SL - 1)";
}
if (type_rdonly.Text == "VL")
{
if (ifEmployeeExist(con, emptime_rdonly.Text))
{
queryUpdate1 = @"UPDATE [LEAVE_EMP] SET EMP_STATUS ='" + a + "'WHERE [EMP_TIME] ='" + emptime_rdonly.Text + "'";
}
queryUpdate2 = "UPDATE LEAVE_ADMIN SET L_SPENT_VL = (L_SPENT_VL + 1),L_REM_VL = (L_REM_VL - 1)";
}
SqlCommand cmd1 = new SqlCommand(queryUpdate1, con);
SqlCommand cmd2 = new SqlCommand(queryUpdate2, con);
cmd2.ExecuteNonQuery();
cmd1.ExecuteNonQuery();
}
if (rejBtn.Checked)
{
if (ifEmployeeExist(con, emptime_rdonly.Text))
{
queryUpdate1 = @"UPDATE [LEAVE_EMP] SET EMP_STATUS ='" + b + "'WHERE [EMP_TIME] ='" + emptime_rdonly.Text + "'";
}
SqlCommand cmd1 = new SqlCommand(queryUpdate1, con);
cmd1.ExecuteNonQuery();
}
con.Close();
}