Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i use the combo box. when i select the combo box i want to check the values with the database comloum if match then delete the rows
Posted

1 solution

C#
button_Click(object sender, EventArgs e)
{
    string str = "DELETE FROM Employee WHERE EmpID = '" + int.parse(EmpIDComboBox.SelectedValue.ToString()) + "'";
    SqlCommand cmd = new SqlCommand(str, con); // con is you SqlConnection instance
    int n = cmd.ExecuteNonQuery();
    
    if(n > 0)
    MessageBox.Show("Employee removed !");
}

-KR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900