User Guide

Table Of Contents
Displaying a RecordSet object in Flash with ActionScript 155
Dim selectContactData As String
'insert Flash parameter into SQL statement
selectContactData = "SELECT ContactName, City, Phone FROM Customers WHERE
Country = \'" + selectedCountryName + "\'"
End If
'create the data adapter object
Dim countryAdapter As System.Data.OleDb.OleDbDataAdapter
'create a dataset object
countryAdapter = New System.Data.OleDb.OleDbDataAdapter(selectAll,
sqlConnection)
'fill the dataset with the query results
countryAdapter.Fill(contactData, "Customers")
'assign the dataset into the flash.datasource property
Flash.DataSource = contactData.Tables("Customers")
'bind the datatable to the custom server control
Flash.DataBind()
'close the SQL connection
sqlConnection.Close()
End Sub
In the code, the contactData DataSet object is created from a SQL query to a database. Next,
the
contactData DataSet object is assigned into the Flash.DataSource property. Finally, the
DataSet object is bound to the Flash Remoting custom server control using the
Flash.DataBind
method and returned to Flash.
Displaying a RecordSet object in Flash with ActionScript
To display a RecordSet object in a Flash UI component, you can use the DataGlue ActionScript
class, which is installed with the Flash Remoting libraries.
You can use the
DataGlue.bindFormatStrings function to display the RecordSet object in a
Flash UI component, such as a ComboBox or a ListBox component. The following example
binds the
re.result RecordSet object to the displayNames ListBox component:
DataGlue.bindFormatStrings(displayNames, re.result, "#ContactName#",
"#customerID#");
In the code, the last two arguments passed to the function (#ContactName# and #customerID#)
are column names in the record set. The
ContactName column is displayed in the UI component,
whereas the
customerID column is returned when a user selects a particular record in the
component.
The following ActionScript code connects to an ASPX page, returns a RecordSet object, and
displays the record set in the
displayNames ComboBox component:
import mx.remoting.Service;
import mx.remoting.RecordSet;
import mx.remoting.DataGlue;
import mx.rpc.ResultEvent;