代码:I used DataTable.Rows.Remove to remove some rows, and use DataAdapter.Update to update this table to datasource, but it doesn't work:public void Delete(T[] values) { foreach (var val in values) { var row = m_Dict[val]; m_Table.Rows.Remove(row); m_Elements.Remove(val); m_Dict.Remove(val); } }public void Apply(SqlDataAdapter adapter) { using (new SqlCommandBuilder(adapter)) { adapter.UpdateBatchSize = 5; adapter.Update(m_Table); } }推荐答案听起来您想要 DataRow.Delete.对此的关键是理解 ADO.NET 中行状态"的概念.DataRow.Delete 将行状态设置为已删除.It sounds like you want DataRow.Delete. The key to this is understanding the concept of "row states" in ADO.NET. DataRow.Delete will set the row state to Deleted. 相关信息:https://msdn.microsoft.com/en-us/library/03c7a3zb(v=vs.110).aspx 这篇关于ado.net 删除行并更新到数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-22 07:49