데이터베이스에서 값을 삭제하는 방법을 썼지 만 영향을받은 행을 확인하면 값은 0이고 처음 if 문으로 계속 들어가는가?데이터베이스에서 삭제
private void workstationDelete()
{
string query = "DELETE FROM test_revision2 where wsid = @wsid and location = '@location'";
try
{
conn = new SqlConnection(connStr);
conn.Open();
SqlCommand cmd = new SqlCommand(query, conn);
cmd.Parameters.AddWithValue("@wsid", Convert.ToInt32(wsid2text.Text));
cmd.Parameters.AddWithValue("@location", deletelocation);
cmd.ExecuteNonQuery();
int rowsaffected = cmd.ExecuteNonQuery();
if (rowsaffected == 0)
{
lblDel.Text = "Sorry Workstation: " + wsid2text.Text + " does not exist in " + deletelocation + ". Therefore it cannot be removed.";
}
else
{
lblDel.Text = "You have successfully removed Workstation: " + Convert.ToInt32(wsid2text.Text) + " in " + deletelocation;
}
conn.Close();
}
catch (SqlException)
{
lblDel.Text = "randome";
}
}