ステータスに基づいて select ステートメントを使用していくつかのレコードを取得する Web サービスを開発しており、ステータスを変更する必要があります。
そのような:
select * from tblx where status='x'
その後
update tblx set status='y' where status='x'
取得したレコードについて。
サンプルコード:
string getpaid = "select top2 * from tblfameface where img_f_p='paid'";
con1 = new SqlConnection(conString1);
con1.Open();
SqlCommand cmd = new SqlCommand(getpaid, con1);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt1 = new DataTable();
da.Fill(dt1);
foreach (DataRow row in dt1.Rows)
{
string updatepaid = "update tblfameface set img_f_p='free' where img_f_p='paid' ";
con1 = new SqlConnection(conString1);
con1.Open();
SqlCommand cmd1 = new SqlCommand(updatepaid, con1);
int temp = cmd1.ExecuteNonQuery();
con1.Close();
}
}
解決方法がわかりません。
助けてもらえますか??