Tag: updatecommand

使用OleDbDataAdapter更新DataTable C#

我一直在尝试使用OleDbDataAdapter来更新DataTable,但对这些命令感到困惑。 因为我有时从不同的表中获取信息,所以我不能使用CommandBuilder。 所以我试图在我的on上创建命令,但发现参数很难。 DataTable.GetChanges返回需要使用INSERT或UPDATE命令的行 – 我想我无法区分它们。 我需要你完成以下内容: DataTable dt = new DataTable(); OleDbDataAdapter da = new OleDbDataAdapter(); // Here I create the SELECT command and pass the connection. da.Fill(dt); // Here I make changes (INSERT/UPDATE) to the DataTable (by a DataGridView). da.UpdateCommand = new OleDbCommand(“UPDATE TABLE_NAME SET (COL1, COL2, …) VALUES (@newVal1, @newVal2, …) WHERE […]