154
Chapter 8: Using Flash Remoting for Microsoft .NET
To display the data from the previous ASPX page, as CustomerCountries.aspx under the
ADOExamples folder, in a DataGrid object called custCountry_grd, the ActionScript code would
look like this:
import mx.remoting.Service;
import mx.remoting.PendingCall;
import mx.rpc.RelayResponder;
import mx.rpc.FaultEvent;
import mx.rpc.ResultEvent;
var custCountryASPX:Service = new Service( "http://localhost/flashremoting/
gateway.aspx", null, "flashremoting.samples.ADOExamples", null, null );
var pc:PendingCall = custCountryASPX.CustomerCountries();
pc.responder = new RelayResponder( this, "gotCountries", "gotFault" );
function gotCountries( re:ResultEvent ):Void {
custCountry_grd.dataProvider = re.result; // got a RecordSet back in result
}
function gotFault( fe:FaultEvent ):Void {
trace( "error-"+fe.fault.faultstring );
}
The following Visual Basic .NET example shows the
Page_Load
method definition in a
code-behind file that performs the same operation as the previous code example:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'create a SQL connection object and open a connection
Dim source1 As String
source1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\inetpub\\wwwroot\\flashremoting\\Samples\\ado\\Northwind.mdb;"
sqlConnection = New OleDb.OleDbConnection()
sqlConnection.ConnectionString = source1
sqlConnection.Open()
'create the SQL statement
Dim selectAll As String
selectAll = "SELECT ContactName, City, Phone, Country FROM Customers"
'Initialize a DataSet contactData and string selectContactData
Dim contactData As New DataSet()
Dim selectContactData As String
'Check for parameters from Flash
If (Flash.Params.Count = 0) Then
'create the SQL statement
Dim selectCountry As String
selectContactData = "SELECT DISTINCT Country FROM Customers ORDER BY
Country ASC"
Else
Dim selectedCountryName As String
'assign parameter passed from Flash to variable
selectedCountryName = Flash.Params(0).ToString()
Содержание FLASH REMOTING MX
Страница 1: ...Using Flash Remoting for Flash MX 2004 ActionScript 2 0...
Страница 8: ...8 Contents...
Страница 62: ...62 Chapter 3 Using the RemotingConnector component Flash Professional only...
Страница 142: ...142 Chapter 7 Using Flash Remoting for Java...