Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 12.0.1 » UltraLite - C 及 C++ 编程 » 应用程序开发 » UltraLite C++ 应用程序开发 » 使用 ULTable 类创建和修改数据

 

更新行

以下过程更新表中的一行。

小心

不要更新行的主键:而是删除该行并添加新行。

 ♦ 更新行
  1. 移动到想要更新的行。

    可以通过滚动浏览表或使用 find 和 lookup 方法在表中进行搜索来移动到某一行。

  2. 进入更新模式。

    例如,以下指令在表 tbl 上进入更新模式。

    tbl->UpdateBegin();
  3. 为要更新的行设置新值。例如,以下指令将缓冲区中的 ID 列设置为 3。

    tbl->SetInt("id", 3);
  4. 执行更新。

    tbl->Update();
    小心

    使用 Find 和 Update 方法时,指针在搜索条件所涉及的列更新后可能不在预期的位置。在某些情况下,建议在更新多个行时使用 SQL 语句。

完成更新操作后,当前行就是已更新的行。

UltraLite C++ API 只能使用 Commit 方法向数据库提交更改。

 另请参见