我正在開發一個web服務,其中我使用基於狀態的select語句獲取一些記錄,然後我需要更改狀態。選擇一些記錄,然後在asp.net c中同步更新它們#
它像:
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();
}
}
我不知道如何解決它。
我可以得到任何幫助嗎?
你試過什麼......並從更新查詢中刪除「frm」.. – Rahul 2013-04-24 11:13:19
@ Rahul-實際上我不知道從哪裏開始。 – Khushbu 2013-04-24 11:15:03
實際上你想要一個代碼或一種方式..什麼是你發現的錯誤或入侵。 – Rahul 2013-04-24 11:18:07