UltraLite for M-Business Anywhere User's Guide
Tutorial: A Sample Application for M-Business Anywhere
This lesson describes code for updating and deleting rows.
Add update and delete functions to your application
Add the Update function to tutorial.js:
function Update()
{
var id;
try {
CustomerTable.updateBegin();
id = CustomerTable.schema.getColumnID("fname");
CustomerTable.setString(id, Cust_FName);
id = CustomerTable.schema.getColumnID("lname");
CustomerTable.setString(id, Cust_LName);
id = CustomerTable.schema.getColumnID("city");
if( Cust_City.length > 0 ) {
CustomerTable.setString(id, Cust_City);
} else {
CustomerTable.setNull(id);
}
id = CustomerTable.schema.getColumnID("phone");
if( Cust_Phone.length > 0 ) {
CustomerTable.setString(id, Cust_Phone);
} else {
CustomerTable.setNull(id);
}
CustomerTable.update();
} catch( ex ) {
alert( "Update error: " + ex.getMessage() );
}
}Add the Delete function to tutorial.js:
function Delete()
{
if( CustomerTable.getRowCount() == 0 ) {
return;
}
CustomerTable.deleteRow();
CustomerTable.moveRelative(0);
}Add the following functions to main.html:
function ClickUpdate()
{
FetchForm();
Update();
DisplayCurrentRow();
}function ClickDelete()
{
Delete();
DisplayCurrentRow();
}Synchronize your M-Business Client and run the application.
SQL Anywhere Studio 9.0.2
版权所有 © 1989–2005 Sybase, Inc. 部分版权所有 © 2001–2005 iAnywhere Solutions, Inc. 保留所有权利。