0
我已經構建了一個xml/aspx頁面,通過sql server檢索producttable中的所有行。此頁面用作xmlfeed。這個XML顯示productdetails,如名稱,價格和股票等,因爲查詢是耗時,我想只檢索已更改的行(例如股票)。有什麼辦法去這個在SQL Server中?如何在長查詢中檢索只更新的產品?
SQL服務器
select name,price,productid
from product
C#
public List<Feed> GetFeed()
{
DataSet dst = new DataSet();
SqlCommand cmd = null;
List<Feed> feedlist = new List<Feed>();
using (SqlConnection conn = new SqlConnection(connectionstring))
{
conn.Open();
cmd = new SqlCommand("[GetFeed]", conn);
cmd.CommandType = CommandType.StoredProcedure;
using (SqlDataReader rs = cmd.ExecuteReader())
{
while (rs.Read())
{
feed feed = new Feed();
feed.productID = rs["ProductID"].ToString();
feed.price = rs["price"].ToString();
feedlist.Add(feed);
}
rs.NextResult();
}
}
return feedlist;
}
public class Feed
{
public string Price { get; set; }
public string Name { get; set; }
public string ProductID { get; set; }
}
protected void Page_Load(object sender, EventArgs e)
{
var feeds = GetFeed();
XElement products =
new XElement("products",
from p in feeds
select new XElement("Product",
new XElement("id", p.ProductID),
new XElement("Price", p.Price),
new XElement("Name", p.Name)
)
);
Response.ContentType = "text/xml";
Response.Write(products.ToString());
Response.End();
}
你能告訴我們一些代碼嗎? – logixologist
請顯示您的查詢,我猜你需要一個'WHERE'子句來過濾結果集。 –
@Karl如何在Where子句中選擇更新的行。我是否需要添加修改的列行? – user603007