我想通过声明
更新Excel文件UPDATE [Sheet1$]
SET Status ='Imported'
WHERE ID IN ( SELECT TOP 5 ID
FROM [Sheet1$]
WHERE Status <>'Imported' OR Status IS NULL )
但Excel中没有任何改变。这是我的代码
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", myConnection);
DataTable dt = new DataTable();
adapter.Fill(dt);
dt.AsEnumerable().Take(5).ToList().ForEach(o => o.SetField("Status", @"Imported"));
dt.AcceptChanges();
string updateSQL = string.Format(@"UPDATE [Sheet1$] SET Status =? WHERE ID IN ( SELECT TOP 5 ID FROM [Sheet1$] WHERE Status <>? OR Status IS NULL )");
adapter.UpdateCommand = new OleDbCommand(updateSQL, myConnection);
adapter.UpdateCommand.Parameters.Add("@Status", OleDbType.Char, 255).SourceColumn = "Status";
adapter.UpdateCommand.Parameters.Add("@OldStatus", OleDbType.Char, 255, "Status").SourceVersion = DataRowVersion.Original;
adapter.Update(dt);
是谁能提供帮助?谢谢:)