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

SQL Anywhere 11.0.1 (中文) » UltraLite - M-Business Anywhere 编程 » 了解 UltraLite for M-Business Anywhere 开发 » 使用 Table API 处理数据

 

访问当前行中的值

任何时候,ULTable 对象都位于以下位置之一。

  • 在表的第一行之前。

  • 在表的某一行上。

  • 在表的最后一行之后。

如果 ULTable 对象放置在行上,您可以使用 ULTable get 方法之一获取当前行每一列的值。

示例

以下代码段会从 tCustomer ULTable 对象中检索出三列的值,并在文本框中显示这些值。

var colID, colFirstName, colLastName;
colID = tCustomer.schema.getColumnID( "id" );
colFirstName = tCustomer.schema.getColumnID( "fname" );
colLastName = tCustomer.schema.getColumnID( "lname" );
alert( tCustomer.getInt( colID ) );
alert( tCustomer.getString( colFirstName ) );
alert( tCustomer.getString( colLastName ) );

也可以使用 ULTable 的方法来设置值。

tCustomer.setString( colLastName, "Kaminski" );

通过将值指派给这些属性,您不用在数据库中变更数据的值。

即使是在该表的第一行之前或最后一行之后,您也可以给属性指派值。但是,您不能从列中获取值。例如,以下代码段会生成一个错误。

tCustomer.moveBeforeFirst();
id = tCustomer.getInt( colID );