如何从已删除的行中检索信息.我已从数据集中的表中删除了一些行,然后使用方法GetChanges(DataRowState.Deleted)来获取已删除的行.我尝试在服务器端的原始表中删除了行,但它完成了这些错误.
System.Data.DeletedRowInaccessibleException:无法通过该行访问已删除的行信息.
什么是正确的方法?这是我的代码,任何建议?谢谢大家
Dataset ds = //get dataset from client side
//get changes
DataTable delRows = ds.Tables[0].GetChanges(DataRowState.Deleted);
//try delete rows in table in DB
if (delRows != null)
{
string connStr = WebConfigurationManager.ConnectionStrings["Employees"].ConnectionString;
conn = new SqlConnection(connStr);
conn.Open();
for (int i = 0; i < delRows.Rows.Count; i++)
{
string cmdText = string.Format("DELETE Tab1 WHERE Surname=@Surname");
cmd = new SqlCommand() { Connection = conn, CommandText = cmdText };
//here is problem, I need get surnames from rows which was deleted
var …Run Code Online (Sandbox Code Playgroud) dataset ×1