WddxRecordset Object

Includes functions that you call as needed when constructing a WDDX recordset.

Functions

Function Syntax
Description
object.addColumn(name)
Adds a column to all rows in a WddxRecordset instance
object.addRows(n)
Adds rows to all columns in a WddxRecordset instance
object.getField(row, col)
Returns the element in a row/column position
object.getRowCount()
Indicates the number of rows in a WddxRecordset instance
object.setField(row, col, value)
Sets the element in a row/column position
object.wddxSerialize(serializer)
Serializes a record set
:

addColumn

Description

Adds a column to all rows in a WddxRecordset instance.

Syntax


object.addColumn( name ) 

Parameters

Parameter
Description
object
Instance name of the WddxRecordset object
name
Name of the column to add

Return value

None.

Usage

Adds a column to every row of the WDDX record set. Initially the new column's values are set to NULL.

Example

This example calls the addColumn function:

// create a new recordset

rs = new WddxRecordset();



// add a new column

rs.addColumn("NewColumn");



// extend the recordset by 3 rows

rs.addRows(3);



// set an element in the first row

// newValue is a previously defined variable

rs.setField(0, "NewColumn", newValue);

addRows

Description

Adds rows to all columns in a WddxRecordset instance.

Syntax


object.addRows( n ) 

Parameters

Parameter
Description
object
Instance name of the WddxRecordset object
n
Integer; number of rows to add

Return value

None.

Usage

This function adds the specified number of rows to every column of a WDDX record set. Initially, the row/column values are set to NULL.

Example

This example calls the addRows function:

// create a new recordset

rs = new WddxRecordset();



// add a new column

rs.addColumn("NewColumn");



// extend the recordset by 3 rows

rs.addRows(3);



// set an element in the first row

// newValue is a previously defined variable

rs.setField(0, "NewColumn", newValue);

getField

Description

Returns the element in the specified row/column position.

Syntax


object.getField( row, col ) 

Parameters

Parameter
Description
object
Instance name of the WddxRecordset object
row
Integer; zero-based row number of the value to return
col
Integer or string; column of the value to be returned.

Return value

Returns the value in the specified row/column position.

Usage

Call this function to access a value in a WDDX record set.

Example

This example calls the getField function (the variable r is a reference to a WddxRecordset instance):

for (row = 0; row < nRows; ++row)

{

  o += "<tr>";

  for (i = 0; i < colNames.length; ++i)

  {

    o += "<td>" + r.getField(row, colNames[i]) + "</td>";

  }

  o += "</tr>";

}

getRowCount

Description

Indicates the number of rows in a WddxRecordset instance.

Syntax


object.getRowCount( ) 

Parameters

Parameter
Description
object
Instance name of a WddxRecordset object

Return value

Integer. Returns the number of rows in the WddxRecordset instance.

Usage

Call this function before a looping construct to determine the number of rows in a record set.

Example

This example calls the getRowCount function:

function dumpWddxRecordset(r)

{ 

// Get row count 

  nRows = r.getRowCount();

...

  for (row = 0; row < nRows; ++row)

...

setField

Description

Sets the element in the specified row/column position.

Syntax


object.setField( row, col, value ) 

Parameters

Parameter
Description
object
Instance name of a WddxRecordset object
row
Integer; row that contains the element to set
col
Integer or string; the column containing the element to set
value
Value to set

Return value

None.

Usage

Call this function to set a value in a WddxRecordset instance.

Example

This example calls the setField function:

// create a new recordset

rs = new WddxRecordset();



// add a new column

rs.addColumn("NewColumn");



// extend the recordset by 3 rows

rs.addRows(3);



// set an element in the first row

// newValue is a previously defined variable

rs.setField(0, "NewColumn", newValue);

wddxSerialize

Description

Serializes a record set.

Syntax


object.wddxSerialize( serializer ) 

Parameters

Parameter
Description
object
Instance name of the WddxRecordset object
serializer
WddxSerializer instance

Return value

Returns a Boolean True if serialization was successful; or False if an error occurs.

Usage

This is an internal function; you do not typically call it.

Example

This example is from the WddxSerializer serializeValue function:

...

else if (typeof(obj) == "object")

{

if (obj == null)

{

// Null values become empty strings

this.write("<string></string>");

}

else if (typeof(obj.wddxSerialize) == "function")

{

// Object knows how to serialize itself

bSuccess = obj.wddxSerialize(this);

}

...




Banner.Novgorod.Ru