私はデータベースから値を削除する方法を書いていましたが、影響を受ける行をチェックすると値は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";
}
}