1

我有这个代码:

OleDbDataAdapter dataAdapter = new OleDbDataAdapter("SELECT col1, col2 "
                                                  + "FROM tab1", 
                                                    connection);

我希望能够这样做:

dataAdapter.UpdateCommand = new OleDbCommand(
            "UPDATE tab1 SET col1 = col1*2, col2 = 300"
          + "WHERE col1 = 5", connection);

如何做到这一点?

4

1 回答 1

2

像这样使用它:

var cmd = new OleDbCommand("UPDATE tab1 SET col1 = col1*2, col2 = 300 WHERE col1 = 5", connection);
cmd.ExecuteNonQuery();

您不需要数据适配器。

于 2012-10-19T12:57:41.920 回答